第1个回答 2012-04-13
#include<stdio.h>
int main(int argc,char *argv[])
{
float result;
float data1,data2;
char op;
scanf("%f%c%f",&data1,&op,&data2);
switch(op)
{
case '+' : result=data1+data2; break;
case'-' : result=data1-data2; break;
case '*' :result=data1*data2; break;
case '/' : if(data2==0) printf("重新输入\n");
else result=data1/data2; break;
default : printf("输入错误\n"); break;
}
printf("%f\n",result);
}
没有编译器调,自己调下吧,思路是这样.