#include <iostream>
using namespace std;
float sum(float a,float b);
float subs(float a, float b);
float multiple(float a, float b);
float division(float a, float b);
int main()
{//main
int a,b;
char o ;
cout<<"input your calculation with operation (+,-,/,*) such as 5+6 : /n ";
cin >> a >> o >> b ;
switch('o')
{
case '+':
sum(float a, float b);
break;
case '-':
subs(float a, float b);
break;
case '*':
multiple(float a, float b);
break;
case '/':
division(float a, float b);
break;
default :
cout << "error, try again " <<endl;
}
return 0;
}//main
float sum(float a,float b)
{//sum
float total= a+b;
return total;
}//sum
float subs(float a, float b)
{//subs
float total=a-b;
return total;
}//subs
float multiple(float a, float b)
{//multiple
float total=a*b;
return total;
}//multiple
float division(float a, float b)
{//division
float total=a/b;
答案 0 :(得分:7)
从表面上看,你最后错过了一个大括号。在操作上,您的switch语句将打开一个常量“o”,而不是变量o。
答案 1 :(得分:0)
变化:
switch('o')
到
switch(o)