Created
October 25, 2011 09:16
-
-
Save wwhhjj/1311974 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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