C语言开设–益智小游戏
程序实现的功能
程序已经实现的功能有:随机产生一位数、二位数、7-66数字之间的四则运算;5个随机产生的一位数的比较;5个随机产生的一位数的排序以及随机产生6个1-100之间数字的排序
运行情况
这是界面
这个是数字运算游戏,包括一位数、二位数以及7-66之间的四则运算
一位数运算
一位数加法运算
两位数除法运算
一位数排序
include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
void ADD1()
{
int d1, sum, a, b;
a = rand() % 10 + 1;
b = rand() % 10 + 1;
printf("%d+%d=", a, b);
sum = a + b;
scanf("%d", &d1);
if (d1 == sum)
printf("答对了,真棒!\n");
else
printf("答错了,很遗憾,继续加油!\n");
system("pause");
}
void RED1()
{
int d1, poor1, a1, b1, c1;
a1 = rand() % 10;
b1 = rand() % 10;
if (a1 >= b1)
printf("%d-%d=", a1,b1);
else if (a1 < b1)
{
c1 = a1;
a1 = b1;
b1 = c1;
printf("%d-%d=", a1,b1);
}
poor1 = a1 - b1;
scanf("%d", &d1);
if (d1 == poor1)
printf("答对了,真棒!\n");
else
printf("答错了,很遗憾,继续加油!\n");
system("pause");
}