#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;
}
#include
#include
#include
main()
{
int i,n,j,sum,m,number=0;
for(j=1;j<=10;j++)
{srand(time(0));
i=rand()%10+1;
n=rand()%10+1;
printf("%d+%d=",i,n);
sum=n+i;
scanf("%d",&m);
if(sum==m) printf("回答对了\t"); number=number+10;
if(sum!=m) printf("回答错了\t");
printf("\n");
}
printf("恭喜你的了%d分\n",number);
}