问问题前先网上找一下相同问题的答案,实在不懂的或脑子卡壳了再问
以下是引用qq273385553在2018-12-22 17:37:01的发言:
#include <stdio.h>
#include <stdlib.h>
void main()
{
int x,y,i,j,k,sum,a=0,b=0;
float c;
printf("测试题数量:");
scanf("%d",&j);
for(i=1;i<=j;i++)
{
srand((unsigned)time(NULL));
x=rand()%100;
y=rand()%100;
sum=x+y;
printf("第%d题:",i);
printf("%d+%d=",x,y);
scanf("%d",&k);
if(k==sum)
{
printf("正确!\n");
a++;
}
else
{
printf("错误!正确结果应该是%d\n",sum);
b++;
}
}
c=a/j;
printf("回答正确%d道题,错误%d道题,正确率为%0.2f%%\n",a,b,c*100);
}
参考一下这个思路,自己写一下,多翻书