/************
break:提前结束循环
continue:不去执行本次循环中continue后面的语句,提前进入下次循环。
************/
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int radius;
double area;
for(radius = 1; radius <= 10; radius++)
{
area = 3.1416 * radius * radius;
if(area >= 120.0)
break;
printf("square = %f\n",area);
}
printf("now radius = %d\n\n",radius-1);
for(radius = 1; radius <= 10; radius++)
{
area = 3.1416 * radius *radius;
if(area < 120.0)
continue;
printf("square = %f\n",area);
}
printf("now radius = %d\n", radius - 1);
system("pause");
return 0;
}
|