如何把以下程序改成c加加程序

CSDN问答 2021-12-30 13:50:36 阅读数:464

程序 以下 改成 加加

include<stdio.h>#include<stdlib.h>#include<time.h>void main(){ int i,j,k=2,num1,num2,sum=0,answer,score=0,xiabiao,temp; char fuhao[2]={'+','-'}; srand((int)time(0)); for(i=1;i<=10;i++) { xiabiao=rand()%2; num1=rand()*50/32767; num2=rand()*50/32767; if(xiabiao==0) { sum=num1+num2;} else { sum=num1-num2;} if(sum>=0&&sum<=50) { j=2; k=1; printf("\n(%d).\n",i); printf("%7d\n",num1); printf("%c\n",fuhao[xiabiao]); printf("%7d\n",num2); printf("------------\n"); printf(" "); scanf("%d",&answer); if(sum==answer) { printf("\n结果:你输入的答案正确! \n\n"); score+=10; } else { while(j<=3) { printf("\n答案错误,请重新输入:"); scanf("%d",&answer); if(sum==answer) { printf("\n结果:你输入的答案正确! \n\n"); k++; if(k==2) { score+=7;} else if(k==3) { score+=5;} break; } else { k++;} j++; } if(j>3) printf("\n该题正确答案为:%d\n",sum); } } else i--; } printf("\n共%d道题目,你的总分为%d\n \n",i-1,score); if (score >= 90) printf(" S M A R T \n"); else if (score < 90 && score >= 80)printf(" G O O D \n"); else if (score < 80 && score >= 70)printf(" O K \n"); else if (score < 70 && score >= 60)printf(" P A S S \n"); else printf(" TRY AGAIN \n");}

版权声明:本文为[CSDN问答]所创,转载请带上原文链接,感谢。 https://ask.csdn.net/questions/7613101