这是我的代码。我尝试修复它,但总是得到相同的错误:“int”之前的预期主表达式。
在第 47、55、63、80、86 行。
而且我之前已经小部分尝试过这个程序并且它有效。它没有标记该错误。
` #包括
using namespace std;
int add (int a, int b)
{
int r;
r=a+b;
return (r);
}
int ssub (int a, int b)
{
int r;
r=a-b;
return (r);
}
int mult(int a, int b)
{
int r;
r=a*b;
return (r);
}
int menu(int a, int b){
int r;
char x;
cout <<"What do you want to do: \na.Adding \n s. Substract \n m. Multiply. \n. e. Exit"<<endl;
cin>>x;
switch (x){
case 'a':
cout << "Give a value for a"<<endl;
cin>>a;
cout <<"Give a value for b"<<endl;
cin>>b;
add (int a, int b); //aquí y en otras líneas me sale: expected primary expression before int.
break;
case 's':
cout << "Give a value for a"<<endl;
cin>>a;
cout <<"Give a value for b"<<endl;
cin>>b;
ssub (int a, int b);
break;
case 'm':
cout << "Give a value for a"<<endl;
cin>>a;
cout <<"Give a value for b"<<endl;
cin>>b;
mult (int a, int b);
break;
case 'e':
x='e';
break;
default:
cout<<"Wrong choice. Run the program again and choose another letter"<<endl;
break;
}
return r;
}
cout<<"The result is " << menu (int a, int b)<<endl;
int main()
{
menu (int a, int b);
return 0;
}
`