小学生测验
# include & ltstdio.h & gt
# include & ltstdlib.h & gt
int main()
{
int TestNum
int Adder1,Adder2,Result
int RandSeed
int I;
int Record = 0;
printf("请输入总测试号!\ n ");
scanf("%d ",& ampTestNum);
if(TestNum & lt;= 0)
{
printf("对不起,请输入正整数\ n ");
退出(0);
}
for(I = 0;我& ltTestNumi++)
{
srand(I);
Adder1 =(无符号)rand()% 100;
Adder2 =(无符号)rand()% 100;
printf("N%d: %2d + %2d =?\n ",I,Adder1,adder 2);
printf("请输入结果\ n ");
scanf("%d ",& amp结果);
if (Result == Adder1 + Adder2)
{
printf("祝贺你!这是对的。\ n \ n ");
record++;
}
其他
{
printf("哦,不,请再试一次\ n \ n ");
}
}
printf("Right:%d\n ",Record);
printf("错误:%d\n ",TestNum-Record);
printf("右比:%3.2f%%\n ",(浮点)记录* 100/TestNum);
返回0;
}
编译环境:C-Free 5.0 @Windows Xp