You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
c-language/小学生测验最终版第三次修改.c

147 lines
2.4 KiB

6 years ago
#include<stdlib.h>
#include<stdio.h>
#include<time.h>
#include<math.h>
typedef struct node
{
int jiajian;
int num1;
int num2;
int trytimes;
}specific;
specific informat[10];
6 years ago
void changesi(int p)
6 years ago
{
if(p==0)
printf("+");
if(p==1)
printf("-");
}
int getgrade(int m)
{
if(m==0)
return 10;
if(m==1)
return 7;
if(m==2)
return 5;
if(m==3)
return 0;
}
6 years ago
int suijishu(int a,int b,int c,int t)
6 years ago
{
int a1,b1;
do
{
a1=rand()%50;
b1=rand()%50;
}while(!(a1+b1>=0&&a1+b1<+50&&a1-b1>=0&&a1-b1<=50));
informat[t].num1=a=a1;
informat[t].num2=b=b1;
informat[t].jiajian=c=rand()%2;
return 0;
}
void show_rank(int sum)
{
printf("\n\n");
printf("<EFBFBD>ܷ֣<EFBFBD>%d\n",sum);
if(sum>=90)
printf("SMART\n");
else if(sum<90&&sum>=80)
printf("GOOD\n");
else if(sum<80&&sum>=70)
printf("OK\n");
else if(sum<70&&sum>=60)
printf("PASS\n");
else
printf("TRE AGAIN\n");
}
int main()
{
srand(time(NULL));
6 years ago
printf("----------pupil exercise system----------\n");
printf("\t\t\t*******************************************************\n");
printf("\t\t\t* <20>˴β<CBB4><CEB2>Ե<EFBFBD><D4B5><EFBFBD>Ŀ<EFBFBD><C4BF>10<31><30> *\n");
printf("\t\t\t* <20><>Ŀ<EFBFBD><C4BF><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>λ<EFBFBD><CEBB><EFBFBD>ļӼ<C4BC> *\n");
printf("\t\t\t* ÿ<><C3BF>10<31>֣<EFBFBD><D6A3>ܷ<EFBFBD>Ϊ100<30>֡<EFBFBD> *\n");
printf("\t\t\t*******************************************************\n");
6 years ago
int t=1,cnt=0,sum=0,a,b,c,ans;
while(t<=10)
{
printf("this is the %d question\n",t);
suijishu(a,b,c,t);
while(cnt<=3)
{
if(c==0)
{
printf("%d+%d=",a,b);
scanf("%d",&ans);
if(a+b==ans)
{
printf("Right\n");
break;
}
else
{
cnt++;
printf("Wrong!!\n");
if(cnt==3)
{
printf("anwser is:%d\n",a+b);
break;
}
}
}
else if(c==1)
{
printf("%d-%d=",a,b);
scanf("%d",&ans);
if(a-b==ans)
{
printf("Right\n");
break;
}
else
{
cnt++;
printf("Wrong!!\n");
if(cnt==3)
{
printf("anwser is:%d\n",a-b);
break;
}
}
}
}
informat[t].trytimes=cnt;
if(cnt==0)
sum+=10;
if(cnt==1)
sum+=7;
if(cnt==2)
sum+=5;
t++;
cnt=0;
printf("\n\n");
printf("--------------------\n");
}
show_rank(sum);
printf("\n\n");
6 years ago
int i;
for(i=1;i<=10;i++)
6 years ago
{
printf("<EFBFBD><EFBFBD>%d<><64>:%d",i,informat[i].num1);
6 years ago
changesi(informat[i].jiajian);
6 years ago
printf("%d=",informat[i].num2);
if(informat[i].jiajian==0)
printf("%d\n",informat[i].num1+informat[i].num2);
else if(informat[i].jiajian==1)
printf("%d\n",informat[i].num1-informat[i].num2);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<>Σ<EFBFBD><CEA3><EFBFBD><EFBFBD><EFBFBD>%d<><64>\n",informat[i].trytimes,getgrade(informat[i].trytimes));
}
6 years ago
float p;
p=sum/10.0;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:%.2f%%\n",p*10);
6 years ago
return 0;
}