更新时间2019-10-20 21:49:15
完整的程序参考
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
srand(time(0)) ;
//ÒÔµçÄÔʱ¼äΪËæ»úÊýÖÖ×ÓÖ»Ö´ÐÐ-´Î¼´¿É
int a=rand ()%100+1; //Éú ³É1~100µÄËæ»úÊý
int b=rand ()%100+1; //Éú³É1~100µÄËæ»úÊý
int c;
int i,an,ct=0;
char s[]="FEDCBA";
for(i=0; i<5; i++) //5¸öÌâÄ¿
{
//±ê×¼´ð°¸
switch(rand()%4)
//Éú³ÉÔËËã·û
{
case 0: //¼Ó·¨
printf("%d+%d=" ,a,b);
c=a+b ;
break;
case 1: //¼õ·¨
printf("%d-%d=",a,b);
c=a-b;
break ;
case 2: //³Ë·¨
printf("%d*%d=" ,a,b);
c=a*b ;
break;
case 3: //³ý·¨
printf("%d/%d=",a,b);
c=a/b;
break ;
}
scanf("%d",&an);
if (an==c)
{
ct++;
printf("ÕýÈ·
");
}
else
printf("´íÎó
");
a=rand ()%100+1;
b=rand ()%100+1;
}
printf("Äã´ð¶ÔÁË%dµÀÌ⣬µÃ·Ö%d£¬µÈ¼¶%c",ct,ct*5,s[ct]);
}
亲测上述程序,能实现这些功能,没有错误啊