Advertisement
lossyy

факин булщит

Jul 6th, 2021
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <iostream>
  3. #include <cstdlib>
  4. #include <ctime>
  5.  
  6. using namespace std;
  7.  
  8. int main_menu ();
  9. void learn_menu();
  10. void test_menu();
  11. void fragment_test(int number);
  12. void full_test();
  13. void print_ftable(int number);
  14. void print_table();
  15. #define TESTS_COUNT 5
  16.  
  17. int main_menu ()
  18. {
  19. system("cls");
  20. int menu_choice = 0;
  21. std::cout<< "1 : learn\n"<<"2 : test"<<endl;
  22. std::cin>>menu_choice;
  23. if (menu_choice == 1)
  24. learn_menu();
  25. else if (menu_choice == 2)
  26. test_menu();
  27. else if (menu_choice==0) return 0;
  28. else main_menu();
  29. }
  30.  
  31. //вывести кусок таблицы для заданного числа
  32. void print_ftable(int number)
  33. {
  34. cout<<endl;
  35. for(int i=0; i<10; i++){
  36. cout<<number<<" x " << i<<" = " << number*i<< endl;
  37. }
  38. cout<<endl;
  39. }
  40.  
  41. //вывести таблицу
  42. void print_table()
  43. {
  44. for (int j=0; j<10;j++){
  45. for(int i=0; i<10; i++){
  46. cout<<j<<" x " << i<<" = " << j*i<< endl;
  47. }
  48. cout<<endl;
  49. }
  50. }
  51.  
  52. //меню выбора числа для зубрёжки
  53. void learn_menu()
  54. {
  55. int menu_choice=0;
  56. int yesno=0;
  57. system("cls");
  58. std::cout<<"input number 1-9 to see pifagor tablefor each number. input 0 to see the whole table. input anything else to go back.\nnumber: ";
  59. std::cin>>menu_choice;
  60. //написать функцию для автоматического вывода таблиц
  61. if (menu_choice!=0)
  62. print_ftable(menu_choice);
  63. else print_table();
  64. std::cout<<"continue learning 1 or 0?\n";
  65. cin>>yesno;
  66. if (yesno==1) learn_menu();
  67. else main_menu();
  68. }
  69.  
  70. //меню выбора числа для проверки
  71. void test_menu()
  72. {
  73. int menu_choice=0;
  74. system("cls");
  75. std::cout<<"input number 1-9 to start testing for each number. input 0 to start the full test. input anything else to go back."<<endl;
  76. std::cin>>menu_choice;
  77. if (menu_choice>=1 && menu_choice<=9)
  78. {
  79. fragment_test(menu_choice);
  80. }
  81. else if (menu_choice==0)
  82. full_test();
  83. else main_menu();
  84. }
  85.  
  86. //проверка отдельных чисел
  87. void fragment_test(int number)
  88. { system("cls");
  89. int score=0;
  90. int yesno=0;
  91. for (int i=0; i<TESTS_COUNT; i++)
  92. {
  93. int rand_number=0;
  94. int answer=0;
  95. int true_answer=0;
  96. srand( time( 0 ) );
  97. rand_number = 1 + rand() % 9;
  98. cout<<number<< " x " << rand_number<<" = ";
  99. cin >> answer;
  100. true_answer=rand_number*number;
  101. if (answer==true_answer){
  102. score++;
  103. cout << "\n\nTHAT'S RIGHT!\nyour score: "<<score<<endl<<endl;
  104. }
  105. else cout << "\n\nYOU'VE MISTAKEN!\nyour score: "<<score<<endl<<endl;
  106. }
  107. cout<<"\nyour score: "<<score<<endl;
  108. cout<<"test for this number again?1 or 0"<<endl;
  109. cin>>yesno;
  110. if(yesno==1) fragment_test(number);
  111. else test_menu();
  112. }
  113.  
  114. void full_test()
  115. {system("cls");
  116. int score=0;
  117. int yesno=0;
  118. for (int i=0; i<TESTS_COUNT; i++)
  119. {
  120. int rand_number=0;
  121. int rand_number2=0;
  122. int answer=0;
  123. int true_answer=0;
  124. srand( time( 0 ) );
  125. rand_number = 1 + rand() % 9;
  126. rand_number2 = 1 + rand() % 9;
  127. cout<<rand_number2<< " x " << rand_number<<" = ";
  128. cin >> answer;
  129. true_answer=rand_number*rand_number2;
  130. if (answer==true_answer){
  131. score++;
  132. cout << "\n\nTHAT'S RIGHT!\nyour score: "<<score<<endl<<endl;
  133. }
  134. else cout << "\n\nYOU'VE MISTAKEN!\nyour score: "<<score<<endl<<endl;
  135. }
  136. cout<<"\nyour score: "<<score<<endl;
  137. cout<<"test again?1 or 0"<<endl;
  138. cin>>yesno;
  139. if(yesno==1) full_test();
  140. else test_menu();
  141. }
  142.  
  143. int main(int argc, char *argv[])
  144. {
  145. main_menu();
  146. return 0;
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement