Skip to content

Instantly share code, notes, and snippets.

@wwhhjj
Created October 25, 2011 09:16
Show Gist options
  • Save wwhhjj/1311974 to your computer and use it in GitHub Desktop.
Save wwhhjj/1311974 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main()
{
float a,b;
char c1;
printf("请输入表达式\n");
scanf("%f%c%f",&a,&c1,&b);
printf("运算结果为:");
switch(c1)
{
case '+': printf("%f+%f=%f\n",a,b,a+b);break;
case '-': printf("%f-%f=%f\n",a,b,a-b);break;
case '*': printf("%f*%f=%f\n",a,b,a*b);break;
case '/': if (b!=0.0)
printf("%f/%f=%f",a,b,a/b);
else
printf("运算错误!除数不可以是0!\n");break;
default : printf("运算错误!除数不可以是0!\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment