gudong1996 于 2016.04.09 13:02 提问

#include
#include
int main()
{
int ret,magic,multiply;//ret,magic分别为计算机产生的1~10之间的随机数，multiply为它们的乘积
int write;
int counter=0;
int score,percent;//score为分数，percent为正确率
//====================1
srand(1);
ret=rand()%10+1;
magic=rand()%10+1;
printf("%d*%d=?\n",magic,ret);
scanf("%d",&write);
if(write==multiply) counter++;
//==================2
srand(2);
ret=rand()%10+1;
magic=rand()%10+1;
printf("%d*%d=?\n",magic,ret);
scanf("%d",&write);
if(write==multiply) counter++;
//======================3
srand(3);
ret=rand()%10+1;
magic=rand()%10+1;
printf("%d*%d=?\n",magic,ret);
scanf("%d",&write);
if(write==multiply) counter++;

``````//====================4
srand(4);
ret=rand()%10+1;
magic=rand()%10+1;
printf("%d*%d=?\n",magic,ret);
scanf("%d",&write);
if(write==multiply) counter++;
//====================5
srand(5);
ret=rand()%10+1;
magic=rand()%10+1;
printf("%d*%d=?\n",magic,ret);
scanf("%d",&write);
if(write==multiply) counter++;
//===============6
srand(6);
ret=rand()%10+1;
magic=rand()%10+1;
printf("%d*%d=?\n",magic,ret);
scanf("%d",&write);
if(write==multiply) counter++;
//=================7
srand(7);
ret=rand()%10+1;
magic=rand()%10+1;
printf("%d*%d=?\n",magic,ret);
scanf("%d",&write);
if(write==multiply) counter++;
//=====================8
srand(8);
ret=rand()%10+1;
magic=rand()%10+1;
printf("%d*%d=?\n",magic,ret);
scanf("%d",&write);
if(write==multiply) counter++;
//==================9
srand(9);
ret=rand()%10+1;
magic=rand()%10+1;
printf("%d*%d=?\n",magic,ret);
scanf("%d",&write);
if(write==multiply) counter++;
//===============10
srand(10);
ret=rand()%10+1;
magic=rand()%10+1;
printf("%d*%d=?\n",magic,ret);
scanf("%d",&write);
if(write==multiply) counter++;
score=counter*10;
percent=counter/10*100;
printf("总分为%d,正确率为%d%%",score,percent);
return 0;
``````

}

5个回答

niu911756178   2016.04.09 13:43

multiply一直没有赋值啊

gudong1996   2016.04.09 13:05

qq423399099      2016.04.09 13:53

multiply没有计算过，一直是个垃圾值，而且楼主为何不用循环。。。

g_base   2016.04.09 14:53

gudong1996   2016.04.09 16:28