12.การทำงานซ้ำๆด้วย For
Last updated
Was this helpful?
Last updated
Was this helpful?
Was this helpful?
for( INITIALIZER; CONDITION; ITERATOR )
{
// เข้ามาทำงานตรงนี้ถ้าเงื่อนไขยังเป็นจริงอยู่
}// แบบไม่มี initializer
for( ; round < 10; round++ )
{
// Do something
}
// แบบมี initializer มากกว่า 1 ตัว
for( int a = 1, b = 2; round < 10; round++ )
{
// Do something
}for(int round = 0; round < 10; round++, a--)
{
// Do something
}for(int round = 0; ;round++)
{
// Do something
}