#include<stdio.h>
#include<string.h>
void menu()
{
printf("\t\t\t\t*****欢迎使用简易运算系统*****\n");
printf("\t\t\t\t***| 1.加法 | ***\n");
printf("\t\t\t\t***| 2.减法 | ***\n");
printf("\t\t\t\t***| 3.乘法 | ***\n");
printf("\t\t\t\t***| 4.除法 | ***\n");
printf("\t\t\t\t***| 0.退出 | ***\n");
printf("\t\t\t\t******************************\n");
printf("\t\t\t\t请输入运行代码:\n");
return;
}
void jia()
{
float x, y;
char m;
float z;
printf("请输入两个数");
scanf("%f,%f",&x,&y);
getchar();
printf("是否继续,请输入(Y/N)");
scanf("%c", &m);
if (strcmp(m, "Y") == 0)
{
z = x + y;
printf("二者和为%f", z);
}
else
{
system("pause"); system("cls");
}
}
void jian()
{
float x, y;
printf("请输入两个数");
scanf("%f,%f", &x, &y);
printf("是否继续,请输入(Y/N)");
char m;
scanf("%c", &m);
getchar();
if (strcmp(m, "Y") == 0)
{
float z;
z = x - y;
printf("二者差为%f", z);
}
else
{
system("pause"); system("cls");
}
}
void cheng()
{
float x, y;
printf("请输入两个数");
scanf("%f,%f", &x, &y);
getchar();
printf("是否继续,请输入(Y/N)");
char m;
scanf("%c", &m);
if (strcmp(m, "Y") == 0) {
float z;
z = x * y;
printf("二者乘积为%f", z);
}
else {
system("pause"); system("cls");
}
}
void chu()
{
float x, y;
printf("请输入两个数");
scanf("%f,%f", &x, &y);
getchar();
printf("是否继续,请输入(Y/N)");
char m;
scanf("%c", &m);
if (strcmp(m, "Y") == 0)
{
float z;
if (y == 0)
{
printf("输入错误!除数不能为0!");
return 0;
}
else
{
z = x / y;
printf("二者商为%f", z);
}
}
else
{
system("pause"); system("cls");
}
}
int main()
{
int a;
menu();
scanf("%d", &a);
while (a != 5)
{
switch (a)
{
case 1:jia(); break;
case 2:jian(); break;
case 3:cheng(); break;
case 4:chu(); break;
case 0:printf("感谢使用\n"); break;
default:break;
}
system("pause"); system("cls");
}
printf("输入错误!!!");
return 0;
}
为什么一到判断是否继续输入Y或者N之后就没有i判断里的结果输出