#include< stdio.h> int main(){int a =(1,2,3); int b =(3,2,1); for(; a> 0; a--)for(; b< 3; b ++); printf("%d",a * b);返回0; }
问题描述:
我已经尝试了很多,但我没有得到解决你会帮我解决这个问题
谢谢你...... !!
I have tried a lot but I didn't get solved will you help me out with this
thank you...!!
#include <stdio.h>
int main()
{
int a=(1, 2, 3);
int b=(3, 2, 1);
for(; a>0; a--)
for(; b<3; b++);
printf("%d ", a*b);
return 0;
}
我的尝试:
想要使用合适的数字进行expiation
答
查看C的逗号运算符。当你知道它是如何工作的时候,你就会知道a和b将被初始化为什么。
Look into C's comma operator. When you know how that works, you will know what a and b will be initialized to.
逗号运算符如下所示:
The Comma operator looks like this:
x = a, b;
它计算表达式 a
,丢弃结果,计算 b
并将其返回。
因此 a
和 b
的代码执行,并将x设置为 b
的值。
您的代码只是该代码的扩展名:有效
It evaluates the expression a
, discards the result, evaluates b
and returns it.
So the code for a
and b
both get executed, and x is set to the value of b
.
Your code is just an extension of that: effectively
x = ((a, b) , c);
所以它评估 a
和 b
,然后评估 c
并设置 x
达到那个价值。
即您的代码是:
So it evaluates a
and b
, then evaluates c
and sets x
to that value.
I.e. Your code is:
int main()
{
int a = 3;
int b = 1;
for(; a>0; a--)
for(; b<3; b++);
printf("%d ", a*b);
return 0;
}