计算器实现
#include <stdio.h>
#include <stdlib.h>/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int a,b,res;
char op;
printf("please input a op b: \n");
scanf("%d%c%d",&a,&op,&b);
if(((op=='/')&&(b==0))&&(op=='+'||op=='-'||op=='*'||op=='/') )
{
printf("erro input!!!\n");return 0;
}
else if (op=='+')
res=a+b;
else if (op=='-')
res=a-b;
else if (op=='*')
res=a*b;
else if((op=='/')&&(b!=0))
res=a/b;
printf("%d%c%d=%d\n",a,op,b,res);
return 0;
}