cout <<"수식을 입력하세요 : "; cin >> x >> c >> y; z=num(x,c,y); cout << x << c << y << " = "<< z <<endl; }
int num(int x, char c, int y) { int z=0;
switch(c) { case '+': z = x+y; break; case '-': z = x-y; break; case '*': z = x*y; break; case '/': z = x/y; break; case '%': z = x%y; break; default : cout << "잘못된 식입니다."<<endl; } return z; }