C语言编程:是否继续?

来源:百度知道 编辑:UC知道 时间:2024/05/09 18:12:22
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int shuru(int num)
{
int a;
srand(num*num+time(0));
a=(rand()+num)%10;//产生10以内的随机数
return a;
}

void main()
{
int i,num,a,b,c,fuhao,error;
error = 0;//错误数置零
num = 100;//使得下面的while循环成立即可
while(!(num>0&&num<10))//只接受10以内的题目数
{
printf("Please input the sum of exam :");
scanf("%d",&num);
}
for(i=0;i<num;i++)//每次出题开始
{
a = shuru(i);//第一个操作数
b = shuru(a);//第二个
fuhao = (shuru(a+b)+b)/a%2;//产生符号 +或者-
switch(fuhao)
{
case 0://+
if(a+b>10)//超过10重新来
{
i--;
break;
}
else
{
printf("%d : %d + %d = ",i+1,a,b);//出题
scanf("%d",&c);//取输入的结果
if(c != a+b)//答案错误
{
printf("Error!\n");
error++;
}
else//正确答案鼓励一下

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int shuru(int num)
{
int a;
srand(num*num+time(0));
a=(rand()+num)%10;//产生10以内的随机数
return a;
}

void main()
{
int i,num,a,b,c,fuhao,error;
char ch='y';; //新添加
error = 0;//错误数置零
num = 100;//使得下面的while循环成立即可
while(ch=='Y'||ch=='y') 新添加
{
while(num>0&&num<10)//只接受10以内的题目数
{
printf("Please input the sum of exam :");
scanf("%d",&num);
}
for(i=0;i<num;i++)//每次出题开始
{
a = shuru(i);//第一个操作数
b = shuru(a);//第二个
fuhao = (shuru(a+b)+b)/a%2;//产生符号 +或者-
switch(fuhao)
{
case 0://+
if(a+b>10)//超过10重新来
{
i--;
break;
}
else
{
printf("%d : %d + %d = ",i+1,a,b);//出题
scanf("%d",&c);//取输入的结果
if(c != a+b)//答案错误