#include
int main()
{
int a,b;
char c;
printf("input a b:" );
scanf("%d %d" , &a,&b );getchar();
printf("operator:" );
scanf("%c", &c ); getchar();
switch( c )
{
case '+':
printf("%d + %d = %.2f\n" , a , b , (float)a+b );
break;
case '-':
printf("%d - %d = %.2f\n" , a , b , (float)a-b );
break;
case '*':
printf("%d * %d = %.2f\n" , a , b , (float)a*b );
break;
case '/':
if ( b==0.00 )
printf("%d / %d = overflow\n" , a , b );
else
printf("%d / %d = %.2f\n" , a , b , (1.0*a)/b );
break;
default:
printf("%d %c %d = error\n" , a , c , b );
break;
}
return 0;
}
//好好学习 天天向上!
是用c还是c++的???