用C语言编写一个计算器程序!要用switch函数,case1 case2那种! 要求:可
发布网友
发布时间:2022-05-07 19:42
我来回答
共2个回答
热心网友
时间:2023-11-08 13:49
38
#include <<a href="https://www.baidu.com/s?wd=stdio.h&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWPWnkm1f1nH-bryDknyRk0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPHRYPWT3Pjbv" target="_blank" class="-highlight">stdio.h</a>>
#include<<a href="https://www.baidu.com/s?wd=math.h&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWPWnkm1f1nH-bryDknyRk0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPHRYPWT3Pjbv" target="_blank" class="-highlight">math.h</a>>
void main()
{
char c;
float a,b,r;
while(1)
{
printf("输入运算式:");
scanf("%f%c%f",&a,&c,&b);
switch(c)
{
case '+':
r = a+b;
break;
case '-':
r = a-b;
break;
case '*':
r = a*b;
break;
case '/':
r = a/b;
break;
case '^':
r = pow(a,b);
break;
case '#':
r = sqrt(a);
break;
default:
printf("不支持此运算!");
continue;
}
printf("%.0f%c%.0f=%.2f\n",a,c,b,r);
}
}
热心网友
时间:2023-11-08 13:49
floatdata1,data2;charop;这两句放在printf 前面,c程序定义变量在前面还少了个}
热心网友
时间:2023-11-08 13:49
38
#include <<a href="https://www.baidu.com/s?wd=stdio.h&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWPWnkm1f1nH-bryDknyRk0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPHRYPWT3Pjbv" target="_blank" class="-highlight">stdio.h</a>>
#include<<a href="https://www.baidu.com/s?wd=math.h&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWPWnkm1f1nH-bryDknyRk0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPHRYPWT3Pjbv" target="_blank" class="-highlight">math.h</a>>
void main()
{
char c;
float a,b,r;
while(1)
{
printf("输入运算式:");
scanf("%f%c%f",&a,&c,&b);
switch(c)
{
case '+':
r = a+b;
break;
case '-':
r = a-b;
break;
case '*':
r = a*b;
break;
case '/':
r = a/b;
break;
case '^':
r = pow(a,b);
break;
case '#':
r = sqrt(a);
break;
default:
printf("不支持此运算!");
continue;
}
printf("%.0f%c%.0f=%.2f\n",a,c,b,r);
}
}
热心网友
时间:2023-11-08 13:49
floatdata1,data2;charop;这两句放在printf 前面,c程序定义变量在前面还少了个}
热心网友
时间:2023-11-08 13:49
38
#include <<a href="https://www.baidu.com/s?wd=stdio.h&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWPWnkm1f1nH-bryDknyRk0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPHRYPWT3Pjbv" target="_blank" class="-highlight">stdio.h</a>>
#include<<a href="https://www.baidu.com/s?wd=math.h&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWPWnkm1f1nH-bryDknyRk0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPHRYPWT3Pjbv" target="_blank" class="-highlight">math.h</a>>
void main()
{
char c;
float a,b,r;
while(1)
{
printf("输入运算式:");
scanf("%f%c%f",&a,&c,&b);
switch(c)
{
case '+':
r = a+b;
break;
case '-':
r = a-b;
break;
case '*':
r = a*b;
break;
case '/':
r = a/b;
break;
case '^':
r = pow(a,b);
break;
case '#':
r = sqrt(a);
break;
default:
printf("不支持此运算!");
continue;
}
printf("%.0f%c%.0f=%.2f\n",a,c,b,r);
}
}
热心网友
时间:2023-11-08 13:49
floatdata1,data2;charop;这两句放在printf 前面,c程序定义变量在前面还少了个}
热心网友
时间:2023-11-08 13:49
38
#include <<a href="https://www.baidu.com/s?wd=stdio.h&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWPWnkm1f1nH-bryDknyRk0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPHRYPWT3Pjbv" target="_blank" class="-highlight">stdio.h</a>>
#include<<a href="https://www.baidu.com/s?wd=math.h&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWPWnkm1f1nH-bryDknyRk0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPHRYPWT3Pjbv" target="_blank" class="-highlight">math.h</a>>
void main()
{
char c;
float a,b,r;
while(1)
{
printf("输入运算式:");
scanf("%f%c%f",&a,&c,&b);
switch(c)
{
case '+':
r = a+b;
break;
case '-':
r = a-b;
break;
case '*':
r = a*b;
break;
case '/':
r = a/b;
break;
case '^':
r = pow(a,b);
break;
case '#':
r = sqrt(a);
break;
default:
printf("不支持此运算!");
continue;
}
printf("%.0f%c%.0f=%.2f\n",a,c,b,r);
}
}
热心网友
时间:2023-11-08 13:49
floatdata1,data2;charop;这两句放在printf 前面,c程序定义变量在前面还少了个}
热心网友
时间:2023-11-08 13:49
38
#include <<a href="https://www.baidu.com/s?wd=stdio.h&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWPWnkm1f1nH-bryDknyRk0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPHRYPWT3Pjbv" target="_blank" class="-highlight">stdio.h</a>>
#include<<a href="https://www.baidu.com/s?wd=math.h&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWPWnkm1f1nH-bryDknyRk0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPHRYPWT3Pjbv" target="_blank" class="-highlight">math.h</a>>
void main()
{
char c;
float a,b,r;
while(1)
{
printf("输入运算式:");
scanf("%f%c%f",&a,&c,&b);
switch(c)
{
case '+':
r = a+b;
break;
case '-':
r = a-b;
break;
case '*':
r = a*b;
break;
case '/':
r = a/b;
break;
case '^':
r = pow(a,b);
break;
case '#':
r = sqrt(a);
break;
default:
printf("不支持此运算!");
continue;
}
printf("%.0f%c%.0f=%.2f\n",a,c,b,r);
}
}
热心网友
时间:2023-11-08 13:49
floatdata1,data2;charop;这两句放在printf 前面,c程序定义变量在前面还少了个}
热心网友
时间:2023-11-08 13:49
38
#include <<a href="https://www.baidu.com/s?wd=stdio.h&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWPWnkm1f1nH-bryDknyRk0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPHRYPWT3Pjbv" target="_blank" class="-highlight">stdio.h</a>>
#include<<a href="https://www.baidu.com/s?wd=math.h&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWPWnkm1f1nH-bryDknyRk0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPHRYPWT3Pjbv" target="_blank" class="-highlight">math.h</a>>
void main()
{
char c;
float a,b,r;
while(1)
{
printf("输入运算式:");
scanf("%f%c%f",&a,&c,&b);
switch(c)
{
case '+':
r = a+b;
break;
case '-':
r = a-b;
break;
case '*':
r = a*b;
break;
case '/':
r = a/b;
break;
case '^':
r = pow(a,b);
break;
case '#':
r = sqrt(a);
break;
default:
printf("不支持此运算!");
continue;
}
printf("%.0f%c%.0f=%.2f\n",a,c,b,r);
}
}
热心网友
时间:2023-11-08 13:49
floatdata1,data2;charop;这两句放在printf 前面,c程序定义变量在前面还少了个}
热心网友
时间:2023-11-08 13:49
38
#include <<a href="https://www.baidu.com/s?wd=stdio.h&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWPWnkm1f1nH-bryDknyRk0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPHRYPWT3Pjbv" target="_blank" class="-highlight">stdio.h</a>>
#include<<a href="https://www.baidu.com/s?wd=math.h&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWPWnkm1f1nH-bryDknyRk0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPHRYPWT3Pjbv" target="_blank" class="-highlight">math.h</a>>
void main()
{
char c;
float a,b,r;
while(1)
{
printf("输入运算式:");
scanf("%f%c%f",&a,&c,&b);
switch(c)
{
case '+':
r = a+b;
break;
case '-':
r = a-b;
break;
case '*':
r = a*b;
break;
case '/':
r = a/b;
break;
case '^':
r = pow(a,b);
break;
case '#':
r = sqrt(a);
break;
default:
printf("不支持此运算!");
continue;
}
printf("%.0f%c%.0f=%.2f\n",a,c,b,r);
}
}
热心网友
时间:2023-11-08 13:49
floatdata1,data2;charop;这两句放在printf 前面,c程序定义变量在前面还少了个}
热心网友
时间:2023-11-08 13:49
38
#include <<a href="https://www.baidu.com/s?wd=stdio.h&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWPWnkm1f1nH-bryDknyRk0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPHRYPWT3Pjbv" target="_blank" class="-highlight">stdio.h</a>>
#include<<a href="https://www.baidu.com/s?wd=math.h&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWPWnkm1f1nH-bryDknyRk0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPHRYPWT3Pjbv" target="_blank" class="-highlight">math.h</a>>
void main()
{
char c;
float a,b,r;
while(1)
{
printf("输入运算式:");
scanf("%f%c%f",&a,&c,&b);
switch(c)
{
case '+':
r = a+b;
break;
case '-':
r = a-b;
break;
case '*':
r = a*b;
break;
case '/':
r = a/b;
break;
case '^':
r = pow(a,b);
break;
case '#':
r = sqrt(a);
break;
default:
printf("不支持此运算!");
continue;
}
printf("%.0f%c%.0f=%.2f\n",a,c,b,r);
}
}
热心网友
时间:2023-11-08 13:49
floatdata1,data2;charop;这两句放在printf 前面,c程序定义变量在前面还少了个}
热心网友
时间:2023-11-08 13:49
38
#include <<a href="https://www.baidu.com/s?wd=stdio.h&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWPWnkm1f1nH-bryDknyRk0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPHRYPWT3Pjbv" target="_blank" class="-highlight">stdio.h</a>>
#include<<a href="https://www.baidu.com/s?wd=math.h&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWPWnkm1f1nH-bryDknyRk0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EPHRYPWT3Pjbv" target="_blank" class="-highlight">math.h</a>>
void main()
{
char c;
float a,b,r;
while(1)
{
printf("输入运算式:");
scanf("%f%c%f",&a,&c,&b);
switch(c)
{
case '+':
r = a+b;
break;
case '-':
r = a-b;
break;
case '*':
r = a*b;
break;
case '/':
r = a/b;
break;
case '^':
r = pow(a,b);
break;
case '#':
r = sqrt(a);
break;
default:
printf("不支持此运算!");
continue;
}
printf("%.0f%c%.0f=%.2f\n",a,c,b,r);
}
}
热心网友
时间:2023-11-08 13:49
floatdata1,data2;charop;这两句放在printf 前面,c程序定义变量在前面还少了个}