满意答案
#include
#include
#include
void Count(int num)
{
int n=0;
for(int i=1; i<=50; i++)
{
int j=rand()%2+1;
int num1 = rand()%num +1;
int num2 = rand()%num +1;
printf("第%d道题:\n",i);
if( j == 1 )
{
printf("%d + %d = ",num1,num2);
printf("请输入你的答案: ");
scanf("%d",&n);
if( num1 + num2 == n)
{
printf("你答对了.\n");
}
else
{
printf("你答错了.\n");
}
}
else
{
printf("%d - %d = ",num1,num2);
printf("请输入你的答案: ");
scanf("%d",&n);
if( num1 - num2 == n)
{
printf("你答对了.\n");
}
else
{
printf("你答错了.\n");
}
}
}
}
int main()
{
srand( time(0) );
Count(10);
return 0;
}
00分享举报