C语言 制作一个可供小学数学运算程序
展开全部
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
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<n;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);
}
#include<stdlib.h>
#include<time.h>
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<n;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);
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用计算器得了、闲的蛋疼
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询