#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void cal(void);
int main()
{ printf("******************************************************\n");
printf("* Now start your using. *\n"
"* If you want to use,please input the order: u *\n"
"* If you want to quit,please input the order: q *\n");
printf("******************************************************\n");
char order;
scanf("%c",&order);
while(1){
switch(order)
{ case 'u': cal();
break;
case 'q': printf("Bye!\n");
return 0;
default:
printf("You input the wrong order,try again.\n");
}
getchar();
printf("Input the order:\n");
scanf("%c",&order);
}
return 0;
}
void cal()
{
printf("Please input:\n");
float a,b,d;
char c;
scanf("%f%c%f=",&a,&c,&b);
switch(c)
{ case '+': d=a+b;break;
case '-': d=a-b;break;
case '*': d=a*b;break;
case '/': d=a/b;break;
}
printf("%f%c%f=%f\n",a,c,b,d);
}
简易计算器(有指令)
最新推荐文章于 2024-09-04 14:45:59 发布