搜索
查看: 315|回复: 0
打印 上一主题 下一主题

那位大神帮忙

[复制链接]
跳转到指定楼层
楼主
 楼主| 发表于 2020-12-23 00:45:15 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
5啊哈币
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. void menu();
  4. void add();
  5. void sub();
  6. void mul();
  7. void div1();



  8. void main()

  9. {

  10. int a; while(1)
  11. {

  12. menu();

  13. printf("Please choose the option:"); scanf("%d",&a);
  14. switch(a)

  15. {

  16. case 1: add(); break;
  17. case 2: sub(); break;
  18. case 3: mul(); break;
  19. case 4: div1();break;

  20. case 5: exit(0); break; default: break;
  21. }


  22. }


  23. }

  24. void menu()

  25. {

  26. printf("**************************************************");

  27. printf("*@@@@@@  Xiao  Xue  Shu  Xue  Ce  Shi  Ruan  Jian @@@@@@@*");
  28. printf("**************************************************");

  29. printf("*----------Please select your operation  *");


  30. printf("*------ 1. +  jia  fa  ce shi  *");
  31. printf("*------ 2. -  jian  fa  ce shi  *");
  32. printf("*------ 3. *  chen  fa  ce shi  *");
  33. printf("*------ 4. /  chu  fa  ce shi  *");


  34. printf("*------ 5. exit the  system  *");



  35. printf("**************************************************");

  36. }



  37. void add()

  38. {

  39. int a,b,c,d,re=0,sum=0; system("cls");
  40. while(1)

  41. {

  42. a=rand()%100; b=rand()%100; printf("%d+%d=",a,b);
  43. scanf("%d",&c); if(c==(a+b))
  44. {

  45. re++; sum++;
  46. printf("^_^Very  good!  You are right!  Will  you  go on?The quantity of question is%dThe right is %d1. Go on 2. Exit",re,sum);
  47. }

  48. else

  49. {


  50. re++;

  51. printf("Sorry!You are wrong! The right answer is %d.Will you go on?The quantity of  question is %dThe right is %d1. Go on 2. Exit",a+b,re,sum);
  52. }

  53. scanf("%d",&d); if(d==2)
  54. break; else system("cls");
  55. }

  56. system("cls");

  57. }

  58. void sub()

  59. {

  60. int a,b,c,d,re=0,sum=0; system("cls");
  61. while(1)

  62. {

  63. a=rand()%100; b=rand()%100;




  64. while((a-b)<0)

  65. {

  66. a=rand()%100; b=rand()%100;
  67. }

  68. printf("%d-%d=",a,b);

  69. scanf("%d",&c);

  70. if(c==(a-b))

  71. {

  72. re++; sum++;
  73. printf("^_^Very  good!  You are right!  Will  you go on?The quantity of question is%dThe right is %d 1. Go on 2. Exit",re,sum);
  74. }

  75. else

  76. {

  77. re++;

  78. printf("Sorry!You are wrong! The right answer is %d.Will you go on?The quantity of question is %dThe right is %d 1. Go on 2.Exit",a-b,re,sum);

  79. }

  80. scanf("%d",&d);

  81. if(d==2)

  82. break; else system("cls");
  83. }

  84. system("cls");


  85. }

  86. void mul()

  87. {

  88. int a,b,c,d,re=0,sum=0; system("cls");
  89. while(1)

  90. {

  91. a=rand()%20; b=rand()%20; printf("%d*%d=",a,b);
  92. scanf("%d",&c); if(c==(a*b))
  93. {

  94. re++; sum++;
  95. printf("^_^  Very  good!  You  are right!  Will  you  go  on?The quantity of question  is%dThe right is %d1.Go on 2.Exit" ,re,sum);

  96. }

  97. else

  98. {

  99. re++;

  100. printf("Soory! You are wrong! The right answer is %d.Will you go on? The quantity of question is %dThe right is %d1.Go  on 2.Exit ",a*b,re,sum);
  101. }

  102. scanf("%d",&d); if(d==2)
  103. break; else
  104. system("cls");

  105. }

  106. system("cls");

  107. }

  108. void div1()

  109. {

  110. int a,b,c,d,sum=0,re=0; system("cls");
  111. while(1)

  112. {


  113. a=rand()%100; b=rand()%100; if(b==0)
  114. b=rand()%100; while((a%b)!=0)
  115. {

  116. a=rand()%100; b=rand()%100; if(b==0)
  117. b=rand()%100;


  118. }


  119. printf("%d/%d=",a,b);

  120. scanf("%d",&c); if(c==(a/b))
  121. {

  122. sum++;

  123. re++;

  124. printf("^_^  Very  good!  You  are  right!  Will  you  go  on?The quantity of question  is%dThe right is %d1.Go on 2.Exit" ,re,sum);
  125. }

  126. else

  127. {

  128. re++;

  129. printf("Soory! You are wrong! The right answer is %d.Will you go on?  The  quantity  of  question  is  %dThe  right  is  %d1.Go  on 2.Exit" ,a/b,re,sum);
  130. }

  131. scanf("%d",&d); if(d==2)
  132. break; else system("cls");
  133. }

  134. system("cls");

  135. }
复制代码

楼主新帖
楼主热帖
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

广播台
特别关注
快速回复 返回顶部 返回列表