#include <stdio.h>
#include <math.h>
int main(){
char x;
double y,z,a;
int i,t;
x1:
printf("请输入一个数字\n");
scanf("%lf",&y);
printf("请输入一个字符\n");
scanf("%s",&x);
if(x == '`'){
t = -1;
}
if(x == '%'){
printf("这是除以100哦\n");
t = 5;
}
if(x == '~'){
printf("几次方\n");
scanf("%lf",&z);
t = 0;
}
if(x=='+'){
printf("加多少\n");
scanf("%lf",&z);
t = 1;
}
if(x == '-'){
printf("减多少\n");
scanf("%lf",&z);
t = 2;
}
if(x == '/'){
printf("除以几\n");
scanf("%lf",&z);
t = 3;
}
if(x == '*'){
printf("乘以几\n");
scanf("%lf",&z);
t = 4;
}
if(t == 1){
a = y + z;
}else{
if(t == 2){
a = y - z;
}else{
if(t == 3){
a = y/z;
}else{
if(t == 4){
a = y*z;
}else{
if(t == -1){
a = sqrt(y);
}else{
if(t == 5){
a = y/100;
}else{
a = pow(y,z);
}
}
}
}
}
}
printf("结果是\n%lf",a);
printf("是否再来一次 0为不\n");
scanf("%d",&i);
if(i){
goto x1;
}
}
C++ 计算器
最新推荐文章于 2024-06-11 08:56:11 发布