早教吧 育儿知识 作业答案 考试题库 百科 知识分享

编制一个程序,完成100以内的整数加减法自动出题和评分系统.要求:1自动出题,加减法运算随机出现;2在减法运算时候,避免出现计算结果为负数的情况.3用户输入计算结果后,判定对或者错,如

题目详情
编制一个程序,完成100以内的整数加减法自动出题和评分系统.
要求:1自动出题,加减法运算随机出现;2在减法运算时候,避免出现计算结果为负数的情况.3用户输入计算结果后,判定对或者错,如果错,则给出正确答案,然后出下一题;4每运算10题,给一个简单的统计结果.
▼优质解答
答案和解析
#include
#include
#include
int a[10]={0},len=0;
int produce_question(){
\x05int x,y,z;
\x05srand((unsigned)time(NULL));
\x05while(1){
\x05\x05x = rand()%100+1;
\x05\x05y = rand()%100+1;
\x05\x05z = rand()%2;
\x05\x05if(z == 0){
\x05\x05\x05printf("%d + %d =",x,y);
\x05\x05\x05return x+y;
\x05\x05}else{
\x05\x05\x05if(x>=y){
\x05\x05\x05\x05printf("%d - %d =",x,y);
\x05\x05\x05\x05return x-y;
\x05\x05\x05}
\x05\x05}
\x05}
}
int judge(int n){
\x05int x;
\x05scanf("%d",&x);
\x05if(n==x){
\x05\x05printf("Correct!\n");
\x05\x05return 1;
\x05}
\x05else {
\x05\x05printf("The right answer is :%d\n",n);
\x05\x05return 0;
\x05}
}
int main()
{
\x05 int temp,res;
\x05 while(1){
\x05\x05 while(len