请问当我输入3的时候,程序的运行结果是多少?为什么?
来源:百度知道 编辑:UC知道 时间:2024/05/30 04:31:34
#include<iostream.h>
int main()
{int a,b,x,y;
cin>>a>>b;
x=2*a/3*(a+b);
y=2*b/3*(a+b);
cout<<x<<y<<endl;
return 0;
}
int main()
{int a,b,x,y;
cin>>a>>b;
x=2*a/3*(a+b);
y=2*b/3*(a+b);
cout<<x<<y<<endl;
return 0;
}
首先你的应该把"include<iostream.h>"改成
"include<iostream>"然后再加一句"using namespace std;"
如果你给a和b都赋为3,那么按照你的程序结果应该输出:1212
毫无疑问,按照表达式及运算符优先级运算的结果就是x=12 ,y=12