/* 求解简单的四则运算表达式 */ #include<stdio.h> int main(void) { double value1,value2; char op; printf("Type in an expression:"); scanf_s("%lf%c%lf",&value1,&op,&value2); if(op=='+') printf("=%.2f ",value1+value2); else if(op=='-') printf("=%.2f ",value1-value2); else if(op=='*') printf("=%.2f ",value1*value2); else if(op=='/') if(value2!=0) printf("=%.2f ",value1/value2); else printf("Divisor can not be 0! "); printf("Unknown operator! "); return 0; }