while
do… while
for
5accp
#include <stdio.h>
void main()
{
printf("accp\n");
printf("accp\n");
printf("accp\n");
printf("accp\n");
printf("accp\n");
}
—
for
while
do...while
while
while
while
5accp #include <stdio.h>
void main()
{
int i=1;
while (i<=5)
{
printf("ACCP\n");
i++;
}
}
while
1 023
21
3while?
While
1+2+3… +99+100
include <stdio.h>
void main()
{
int i=1;
int sum=0;
while (i<=100)
{
sum+=i;
i++;
}
printf("sum=%d\n",sum);
}
while
1~10
1~100
do… while
do
while
do… while
5accp
#include <stdio.h>
void main()
{
int i=1;
do
{
printf("ACCP\n");
i++;
}while (i<=5);
}
do… while
do...while
do...while
1~10
1+2+3… +99+100
for
for (;;)
{
}
for
5accp #include <stdio.h>
void main()
{
int i;
for (i=1;i<=5;i++)
{
printf("ACCP\n");
}
}
for
for
1+2+3… +99+100
for
#include <stdio.h>
void main()
{
int i;
int sum=0;
for (i=1;i<=100;i++)
{
sum+=i;
}
printf("sum=%d\n",sum);
}
for
1 for,
for for
for
for for
……
for
#include <stdio.h>
void main()
{
int i=1;
int sum=0;
for (;i<=100;i++)
{
sum+=i;
}
printf("sum=%d\n",sum);
}
for
#include <stdio.h>
void main()
{
int i=1;
int sum=0;
for (;i<=100;)
{
sum+=i;
i++;
}
printf("sum=%d\n",sum);
}
1~10
1~100
#include <stdio.h>
void main()
{
int i,j;
for (i=1;i<=5;i++)
{
for (j=1;j<=i;j++)
{
printf("*");
}
putchar('\n');
}
}
for (var1=;var1<=var1+=)
{
for (var2=;var2<=var2+=)
{… }
}…… …,..
break
Switchcase
For(1)
{
If (2)
Break;
……
}
break
#include <stdio.h>
void main()
{
int i;
int sum=0;
for (i=1;i<=100;i++)
{
sum+=i;
if (sum>2500)/* 2500*/
{
break;
}
}
printf("sum=%d,i=%d",sum,i);
}
1~10100,
Continue
For(1)
{
If (2)
continue;
……
}
continue
#include <stdio.h>
void main()
{
int i;
for (i=1;i<=100;i++)
{
if (i%3==0)
{
continue;
}
else
printf("%d\n",i);
}
}
—— goto
goto C
goto ;
goto
C? #include <stdio.h>? void main()
{
int i;
int sum=0;
for (i=1;i<=100;i++)
{
sum+=i;
if (sum>=2500)
{
goto leap;
}
}
leap:printf("sum=%d,i=%d\n",sum,i);
}
while for
for
do… while
while for
for
do… while
100,95,90…… 105
5
,.
)
*
* *
* * *
* * * *