求救啊 c++

来源:百度知道 编辑:UC知道 时间:2024/05/15 03:50:12
#include <iostream.h>
void main()
{
int a=3,b=5,ab,bb;
ab=a%3*5(int)(5/7)+b;
bb=(float)(a+b)/2;
cout<<"1题答案"<<ab<<endl;
cout<<"2题答案"<<bb;
}
总提示有一个错误.
--------------------Configuration: Cpp1 - Win32 Debug--------------------
Compiling...
Cpp1.cpp
C:\Documents and Settings\user\My Documents\Cpp1.cpp(5) : error C2144: syntax error : missing ')' before type 'int'
C:\Documents and Settings\user\My Documents\Cpp1.cpp(5) : error C2064: term does not evaluate to a function
C:\Documents and Settings\user\My Documents\Cpp1.cpp(5) : error C2059: syntax error : ')'
C:\Documents and Settings\user\My Documents\Cpp1.cpp(6) : warning C4244: '=' : conversion from 'float' to 'int', possible loss of data
执行 cl.exe 时出错.

Cpp1.obj - 1 error(s), 0 w

#include <iostream.h>
void main()
{
int a=3,b=5,ab;
float bb;
// ab=a%3*5(int)(5/7)+b; ////这里
///////
ab=a % 3 * 5 /*这里要加一个运算符啊,如 + */ + (int)(5/7) + b;
bb=(float)(a+b)/2; // bb改为float型,不过一般都用double
cout<<"1题答案"<<ab<<endl;
cout<<"2题答案"<<bb;
}

ab=a%3*5(int)(5/7)+b;
5的后面少一个运算符。