C语言 100以内加减法

2020-04-22 社会 143阅读
怎么还问呢?不是已经帮你了吗?
#include
#include
#include
int jia()
{ int num1,num2,num;
system("cls");
srand(time(NULL));
do
{
num1=rand()%100;
num2=rand()%100;
num=num1+num2;
}while(num>100);
printf("%d+%d=",num1,num2);
return num;
}
int jian()
{ int num1,num2,num;
system("cls");
srand(time(NULL));
do
{
num1=rand()%100;
num2=rand()%100;
num=num1-num2;
}while(num>100||num<0);
printf("%d-%d=",num1,num2);
return num;
}
int cheng()
{ int num1,num2,num;
system("cls");
srand(time(NULL));
do
{
num1=rand()%100;
num2=rand()%100;
num=num1*num2;
}while(num>100);
printf("%d*%d=",num1,num2);
return num;
}
main()
{ int a,c,i,n,r;
float aver,grade=0;
srand(time(NULL));
printf("请输入题目数量:");
scanf("%d",&n);
aver=100.0/n; //百分制
for(i=0;i { c=rand()%(10/3);
switch(c)
{
case 0:r=jia();break;
case 1:r=jian();break;
case 2:r=cheng();break;
}
scanf("%d",&a);
if(a==r)
grade+=aver;
}
system("cls");
printf("成绩:%.1f\n",grade);
}
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com