01:简单算术表达式求值
总Time Limit: - 1000ms
Memory Limit: - 65536kB
Description两位正整数的简单算术运算(只考虑整数运算),算术运算为:
+,加法运算;
-,减法运算;
*,乘法运算;
/,整除运算;
%,取余运算。
算术表达式的格式为(运算符前后可能有空格):
运算数 运算符 运算数
请输出相应的结果。
Input- 一行算术表达式。
Output- 整型算数运算的结果(结果值不一定为2位数,可能多于2位或少于2位)。
Sample Input32+64
Sample Output96
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
using namespace std;
int a,b;
char c;
int main()
{
cin>>a>>c>>b;//cin>>会过滤掉不可见字符
(如 空格 回车,TAB 等)像scanf或者getchar();
就不行了所以错了2遍
if(c=='+')cout<<a+b;
if(c=='-')cout<<a-b;
if(c=='*')cout<<a*b;
if(c=='/')cout<<a/b;
if(c=='%')cout<<a%b;
}
made by Cynthia King