#include
#include
#include
#include
void Menu();
void Plus();
void Minus();
void Multiply();
void Dir();
int main()
{
int n, flag = 0;
while(1)
{
Menu();
do
{
flag = 0;
scanf("%d", &n);
switch(n)
{
case 1: Plus(); break;
case 2: Minus(); break;
case 3: Multiply(); break;
case 4: Dir(); break;
case 5: exit(0);
default:
{
printf("输入有误, 请重新输入!");
flag = 1;
}
}
}
while(flag);
}
return 0;
}
void Menu()
{
system("cls");
printf("\t\t欢迎来到小学生算数训练\n");
printf("\t\t\t1.加法训练\n");
printf("\t\t\t2.减法训练\n");
printf("\t\t\t3.乘法训练\n");
printf("\t\t\t4.除法训练\n");
printf("\t\t\t5.退出\n");
printf("\t\t\t请选择: ");
}
void Plus()
{
system("cls");
printf("\t\t现在是加法训练\n\n");
srand((unsigned)time(NULL));
int plu[10][4];
int m, n, result, input;
for(int i = 0; i < 10; i++)
{
m = rand() % 10;
n = rand() % 10;
printf("请计算: %d + %d = ", m, n);
result = m + n;
scanf("%d", &input);
if(input != result)
printf("真可惜, 回答错误, 请再接再厉!\n");
else
printf("恭喜你, 回答正确, 请继续加油!\n");
plu[i][0] = m;
plu[i][1] = n;
plu[i][2] = input;
plu[i][3] = result;
}
printf("===============十道题目回答如下=================\n\n");
for(int j = 0; j < 10; j++)
{
printf("%d + %d = %d\t", plu[j][0], plu[j][1], plu[j][2]);
if(plu[j][2] != plu[j][3])
printf("(正确答案为%d)", plu[j][3]);
printf("\n");
}
printf("输入任意键返回主菜单\n");
getch();
}
void Minus()
{
system("cls");
printf("\t\t现在是减法训练\n\n");
srand((unsigned)time(NULL));
int plu[10][4];
int m, n, result, input;
for(int i = 0; i < 10; i++)
{
do
{
m = rand() % 10;
n = rand() % 10;
}while(m < n);
printf("请计算: %d - %d = ", m, n);
result = m - n;
scanf("%d", &input);
if(input != result)
printf("真可惜, 回答错误, 请再接再厉!\n");
else
printf("恭喜你, 回答正确, 请继续加油!\n");
plu[i][0] = m;
plu[i][1] = n;
plu[i][2] = input;
plu[i][3] = result;
}
printf("===============十道题目回答如下=================\n\n");
for(int j = 0; j < 10; j++)
{
printf("%d - %d = %d\t", plu[j][0], plu[j][1], plu[j][2]);
if(plu[j][2] != plu[j][3])
printf("(正确答案为%d)", plu[j][3]);
printf("\n");
}
printf("输入任意键返回主菜单\n");
getch();
}
void Multiply()
{
system("cls");
printf("\t\t现在是乘法训练\n\n");
srand((unsigned)time(NULL));
int plu[10][4];
int m, n, result, input;
for(int i = 0; i < 10; i++)
{
m = rand() % 10;
n = rand() % 10;
printf("请计算: %d * %d = ", m, n);
result = m * n;
scanf("%d", &input);
if(input != result)
printf("真可惜, 回答错误, 请再接再厉!\n");
else
printf("恭喜你, 回答正确, 请继续加油!\n");
plu[i][0] = m;
plu[i][1] = n;
plu[i][2] = input;
plu[i][3] = result;
}
printf("===============十道题目回答如下=================\n\n");
for(int j = 0; j < 10; j++)
{
printf("%d * %d = %d\t", plu[j][0], plu[j][1], plu[j][2]);
if(plu[j][2] != plu[j][3])
printf("(正确答案为%d)", plu[j][3]);
printf("\n");
}
printf("输入任意键返回主菜单\n");
getch();
}
void Dir()
{
system("cls");
printf("\t\t现在是除法训练\n\n");
srand((unsigned)time(NULL));
int plu[10][4];
int m, n, result, input;
for(int i = 0; i < 10; i++)
{
do
{
m = rand() % 10;
n = rand() % 10;
}while(m == 0 || n == 0);
result = m * n;
int temp;
temp = m;
m = result;
result = temp;
printf("请计算: %d / %d = ", m, n);
scanf("%d", &input);
if(input != result)
printf("真可惜, 回答错误, 请再接再厉!\n");
else
printf("恭喜你, 回答正确, 请继续加油!\n");
plu[i][0] = m;
plu[i][1] = n;
plu[i][2] = input;
plu[i][3] = result;
}
printf("===============十道题目回答如下=================\n\n");
for(int j = 0; j < 10; j++)
{
printf("%d / %d = %d\t", plu[j][0], plu[j][1], plu[j][2]);
if(plu[j][2] != plu[j][3])
printf("(正确答案为%d)", plu[j][3]);
printf("\n");
}
printf("输入任意键返回主菜单\n");
getch();
}
200分
等会儿把程序给你,我正在写。有问题hi百度聊