Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int main_menu ();
- void learn_menu();
- void test_menu();
- void fragment_test(int number);
- void full_test();
- void print_ftable(int number);
- void print_table();
- #define TESTS_COUNT 5
- int main_menu ()
- {
- system("cls");
- int menu_choice = 0;
- std::cout<< "1 : learn\n"<<"2 : test"<<endl;
- std::cin>>menu_choice;
- if (menu_choice == 1)
- learn_menu();
- else if (menu_choice == 2)
- test_menu();
- else if (menu_choice==0) return 0;
- else main_menu();
- }
- //вывести кусок таблицы для заданного числа
- void print_ftable(int number)
- {
- cout<<endl;
- for(int i=0; i<10; i++){
- cout<<number<<" x " << i<<" = " << number*i<< endl;
- }
- cout<<endl;
- }
- //вывести таблицу
- void print_table()
- {
- for (int j=0; j<10;j++){
- for(int i=0; i<10; i++){
- cout<<j<<" x " << i<<" = " << j*i<< endl;
- }
- cout<<endl;
- }
- }
- //меню выбора числа для зубрёжки
- void learn_menu()
- {
- int menu_choice=0;
- int yesno=0;
- system("cls");
- 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: ";
- std::cin>>menu_choice;
- //написать функцию для автоматического вывода таблиц
- if (menu_choice!=0)
- print_ftable(menu_choice);
- else print_table();
- std::cout<<"continue learning 1 or 0?\n";
- cin>>yesno;
- if (yesno==1) learn_menu();
- else main_menu();
- }
- //меню выбора числа для проверки
- void test_menu()
- {
- int menu_choice=0;
- system("cls");
- 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;
- std::cin>>menu_choice;
- if (menu_choice>=1 && menu_choice<=9)
- {
- fragment_test(menu_choice);
- }
- else if (menu_choice==0)
- full_test();
- else main_menu();
- }
- //проверка отдельных чисел
- void fragment_test(int number)
- { system("cls");
- int score=0;
- int yesno=0;
- for (int i=0; i<TESTS_COUNT; i++)
- {
- int rand_number=0;
- int answer=0;
- int true_answer=0;
- srand( time( 0 ) );
- rand_number = 1 + rand() % 9;
- cout<<number<< " x " << rand_number<<" = ";
- cin >> answer;
- true_answer=rand_number*number;
- if (answer==true_answer){
- score++;
- cout << "\n\nTHAT'S RIGHT!\nyour score: "<<score<<endl<<endl;
- }
- else cout << "\n\nYOU'VE MISTAKEN!\nyour score: "<<score<<endl<<endl;
- }
- cout<<"\nyour score: "<<score<<endl;
- cout<<"test for this number again?1 or 0"<<endl;
- cin>>yesno;
- if(yesno==1) fragment_test(number);
- else test_menu();
- }
- void full_test()
- {system("cls");
- int score=0;
- int yesno=0;
- for (int i=0; i<TESTS_COUNT; i++)
- {
- int rand_number=0;
- int rand_number2=0;
- int answer=0;
- int true_answer=0;
- srand( time( 0 ) );
- rand_number = 1 + rand() % 9;
- rand_number2 = 1 + rand() % 9;
- cout<<rand_number2<< " x " << rand_number<<" = ";
- cin >> answer;
- true_answer=rand_number*rand_number2;
- if (answer==true_answer){
- score++;
- cout << "\n\nTHAT'S RIGHT!\nyour score: "<<score<<endl<<endl;
- }
- else cout << "\n\nYOU'VE MISTAKEN!\nyour score: "<<score<<endl<<endl;
- }
- cout<<"\nyour score: "<<score<<endl;
- cout<<"test again?1 or 0"<<endl;
- cin>>yesno;
- if(yesno==1) full_test();
- else test_menu();
- }
- int main(int argc, char *argv[])
- {
- main_menu();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement