为您找到"

...{ int a=1,b=10; do {b-=a;a++;}while(b--<0); printf(″a=%d,b...

"相关结果约100,000,000个

这道题怎么做?. main () { int a=1,b=10; do {b-=a;a++;}while (b--<0); printf ...

是这样的,int a=1,b=10;此时a是1,b是10.然后do b=b-a,a++,如果b<0,继续循环,否则跳出。每判断一次b要减1,最后输出a,b的值。按照这个思路第一次while循环b是9,a是2。此时b不小于0,跳出循环,但是b--还是要执行的,也就是说b为8,输出a=2,b=8

C Programming while loops - Stack Overflow

Oh, this is evil. Reformatting the code a bit should show what's happening: a=10; do { while(a++<10); } while(a++<=11); So. a is initially set to 10.We enter the do while loop. The only statement in the do while loop is while( a++ < 10 );.Remember that the expression a++ evaluates to the current value of a, and as a side effect increments a.. So, a++ < 10 is evaluated.

a=1;b=10; do {b-=a;a++; }while (b--<0);解释代码 - CSDN

文章浏览阅读195次。这段代码的作用是不断地执行循环体中的操作直到满足条件为止。 具体地说,变量a被初始化为1,变量b被初始化为10。然后,一直执行循环体中的操作,直到满足b--<0的条件为止

c - printf("%d %d %d\n",++a, a++,a) output - Stack ... - Stack Overflow

a++ means "do something with a, and then increment it afterwards". ++a means "increment a first, then do something with the new value". In your particular Example, printf evaluates a++ first, reads 10 and prints it and only then increments it to 11. printf then evaluates ++a, increments it first, reads 12 and prints it out.

#include main() {int a=1,b=10; do{b-=a;a++;}while(b--<0);printf("a=%d,b ...

do{}while() 循环的运行过程是:先运行 {} 里面的语句,然后再进行条件判断 。 所以,上面的代码是先执行 b-=a ; // b = 9 ;

#include Void main ( ) { int a=1,b=10; do {b-=a;a++;} while ...

楼上的,不要误人啊,很明显是先执行b-=a然后a++,最后判断while的条件b--<0如果满足就再跳回去从b-=a执行,如果不满足条件就直接退出循环这里很明显不满足b<0所以结果为a=2,b=8.b=8是因为循环完了过后还要执行b--所以就9-1=8 望采纳

#include int main () { int a=1, b=10; do { b-=a; a++; } while ...

这段代码的结果是输出"a=10, b=-1"。 代码中定义了两个变量a和b,分别初始化为1和10。然后在do-while循环中,先执行b-=a这一语句,即将b减去a的值,然后a自增1。接着判断b是否小于0,若小于0则继续执行循环体内的语句,否则跳出循环。

告诉我这段代码的结果,并进行解释: #include int main() { int a=1, b=10; do { b ...

这段代码的结果是输出"a=10, b=-1"。 代码中定义了两个变量a和b,分别初始化为1和10。然后在do-while循环中,先执行b-=a这一语句,即将b减去a的值,然后a自增1。接着判断b是否小于0,若小于0则继续执行循环体内的语句,否则跳出循环。

c语言循环案例 - TBHacker - 博客园

do while. #include #include int main() { int a = 1,b = 10; do { b -= a; a++; } while (b-- < 0); printf("%d\n",b); // 8 return 0; }

what will be the output when following code is executed? - Examveda

Solution(By Examveda Team) Step 1: Initialize a with the value 10. Step 2: Declare b without initialization (the initial value is undefined). Step 3: Evaluate a++ (post-increment): - The current value of a is 10. - After evaluating a++, a becomes 11. Step 4: Evaluate ++a (pre-increment): - ++a increments a to 12 and returns the updated value, which is 12. Step 5: Sum the values obtained in ...

相关搜索