do-while语句中的执行代码块是从上到下运行还是同时运行的?
int sum = 0; //定义计算结果变量sum
int i =1; //定义循环数字变量i
int flag = 1; //定义符号状态变量flag
//do-while循环
do{
i++;
sum=sum+flag*i;
flag=-flag;
}while(i<=100);
printf("sum=%d\n",sum);
int sum = 0; //定义计算结果变量sum
int i =1; //定义循环数字变量i
int flag = 1; //定义符号状态变量flag
//do-while循环
do{
i++;
sum=sum+flag*i;
flag=-flag;
}while(i<=100);
printf("sum=%d\n",sum);
2017-10-17
举报