知識社群登入
位置: AutoCAD開放式教學 > 討論區 > 討論
BREAK, CONTINUE, GOTO
1樓
FOR I=1 TO 40 STEP 1
   IF (偶數) CONTINUE

   IF (質數) GOTO L100;

   IF (I == 23) BREAK;

   PRINT I;

   L100: CONTINUE
NEXT I


2樓
// fille: XXX.CPP

#include <stdio.h>

// Example of the goto statement
void main()
{
    int i, j;
    for ( i = 0; i < 10; i++ )
    {
        printf( "Outer loop executing. i = %d\n", i );
        for ( j = 0; j < 3; j++ )
        {
            printf( " Inner loop executing. j = %d\n", j );
            if ( i == 5 )
                goto stop;
        }
    }
    /* This message does not print: */
    printf( "Loop exited. i = %d\n", i );
stop: printf( "Jumped to stop. i = %d\n", i );
}

#if 0
int main()
{
//
return 0;
}// end of main()
#endif

// end of file