#include "stdio.h" void main() { int a,b,c,t; a=1;b=2;c=2; while(a<b<c)

#include &quot;stdio.h&quot;void main(){int a,b,c,t; a=1;b=2;c=2; while(a&lt;b&lt;c) {t=a;a=b;b=t;c--;} printf(&quot;%d,%d,%d&quot;,a,b,c); }运行结果是 1,2,0 后面的0是怎么计算的?
2026年09月28日 10:17
有1个网友回答
网友(1):

因为循环执行了两次。比较a

#include "stdio.h"
void main()
{
int a, b, c, t,cmp;
   a=1; b=2; c=2;
int loop_count = 0;
   while((cmp = a < b) < c)  
   {
   printf("cmp = %d\n", cmp);
t=a;
a=b;
b=t;
c--;
++loop_count;
}
   printf("%d,%d,%d\n", a, b, c);
   printf("loop count = %d\n", loop_count);
}