#include <stdio.h>
#include <stdlib.h>
int SimpleCalculator()
{
char ch;
int sum, ci;
scanf("%d", &ci);
scanf("%c", &ch);
while(ch != '=')
{
scanf("%d", &sum);
switch (ch)
{
case '+': ci += sum; break;
case '-': ci -= sum; break;
case '*': ci *= sum; break;
case '/':
if (!sum)
{
printf("ERROR");
return 0;
}
ci /= sum; break;
default:
printf("ERROR");
return 0;
}
scanf("%c", &ch);
}
printf("%d", ci);
}
int main()
{
SimpleCalculator();
return 0;
}
简单计算器2020.09.13
最新推荐文章于 2021-05-26 15:57:15 发布