#include <stdlib.h>
#include <string.h>
#include <math.h>
#define _CRT_SECURE_NO_WARNINGS
void ArithmeticMenu() { //排序子菜单 数学求四则运算
printf("*****************************\n");
printf("*\t\t1.加法\t\t*\n");
printf("*\t\t2.减法\t\t*\n");
printf("*\t\t3.乘法\t\t*\n");
printf("*\t\t4.除法\t\t*\n");
printf("******************************\n");
}
void Arithmetic() {
double x, double y;
int choice;
printf("请输入您的选择:\n");
scanf_s("%d", &choice);
switch (choice) {
case 1:printf("请输入要算的数字:\n");
scanf_s("%lf+%lf", &x, &y);
printf("x+y=%lf\n", x + y);
break;
case 2:printf("请输入要算的数字:\n");
scanf_s("%lf-%lf", &x, &y);
printf("x-y=%lf\n", x - y);
break;
case 3:printf("请输入要算的数字:\n");
scanf_s("%lf*%lf", &x, &y);
printf("x*y=%lf\n", x * y);
break;
case 4:printf("请输入要算的数字:\n");
scanf_s("%lf %lf", &x, &y);
printf("x/y=%lf\n", x / y);
break;
default:printf("请重新输入\n");
break;
}
}
int main()
{
ArithmeticMenu();
Arithmetic();
return 0;
}
c++报错如图片所示这怎么改呐
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
4条回答 默认 最新
- 快乐鹦鹉 2023-03-10 14:27关注
#include <stdio.h>你都没加啊
double x,y;修改如下:
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #define _CRT_SECURE_NO_WARNINGS void ArithmeticMenu() { //排序子菜单 数学求四则运算 printf("*****************************\n"); printf("*\t\t1.加法\t\t*\n"); printf("*\t\t2.减法\t\t*\n"); printf("*\t\t3.乘法\t\t*\n"); printf("*\t\t4.除法\t\t*\n"); printf("******************************\n"); } void Arithmetic() { double x, y; int choice; printf("请输入您的选择:\n"); scanf_s("%d", &choice); switch (choice) { case 1:printf("请输入要算的数字:\n"); scanf_s("%lf+%lf", &x, &y); printf("x+y=%lf\n", x + y); break; case 2:printf("请输入要算的数字:\n"); scanf_s("%lf-%lf", &x, &y); printf("x-y=%lf\n", x - y); break; case 3:printf("请输入要算的数字:\n"); scanf_s("%lf*%lf", &x, &y); printf("x*y=%lf\n", x * y); break; case 4:printf("请输入要算的数字:\n"); scanf_s("%lf/%lf", &x, &y); printf("x/y=%lf\n", x / y); break; default:printf("请重新输入\n"); break; } system("pause"); } int main() { ArithmeticMenu(); Arithmetic(); system("pause"); return 0; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报 编辑记录
悬赏问题
- ¥15 网络设备配置与管理这个该怎么弄
- ¥20 机器学习能否像多层线性模型一样处理嵌套数据
- ¥20 西门子S7-Graph,S7-300,梯形图
- ¥50 用易语言http 访问不了网页
- ¥50 safari浏览器fetch提交数据后数据丢失问题
- ¥15 matlab不知道怎么改,求解答!!
- ¥15 永磁直线电机的电流环pi调不出来
- ¥15 用stata实现聚类的代码
- ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
- ¥20 docker里部署springboot项目,访问不到扬声器