Может ли обратный отсчет работать в фоновом режиме
В настоящее время я делаю программу викторины. И я создал обратный отсчет, но так как c++ делает действия строка за строкой, я получаю то, что хочу. Я хочу работать одновременно с тестами.
Что я уже пробовал:
вот одна часть моей программы
void QUIZ::OOP2() { system("cls"); QUIZ("OOP2"); int oop2_time = 100; for (int i = oop2_time; oop2_time >= 0; i--) { cout << "\t\t\tQuestions of OOP2\n\n"; line(); cout << "1. Evaluate !(1 && !(0 || 1)) \n"; line(); cout << "A)True \t B) False \t C)Error\t D)None of these\n"; CorrectA(var); _getch(); system("cls"); line(); cout << "2.Cout<<((4*2/2)%2); will display\n"; line(); cout << "a) 4 b) 2 c) 0 d) 1\n"; CorrectC(var); _getch(); system("cls"); line(); cout << "3.___________ is a NOT a valid identifier \n"; line(); cout << " a) num2 b) while c) my_number d) INT \n"; CorrectB(var); _getch(); system("cls"); line(); cout << "4.The precedence of athematic operators is (highest to lowest from left to right)? \n"; line(); cout << " a) %, *, / , + b). *, +, /,% c). %, +, *, / d). %, *, +, / \n"; CorrectB(var); _getch(); system("cls"); line(); cout << "5. Which operator has the highest priority (precedence) \n"; line(); cout << " a) * b) + c) ( ) d) / \n"; CorrectA(var); _getch(); system("cls"); line(); cout << "6.The keyword "default " can be written anywhere in switch block \n"; cout << " a) True b) False \n"; line(); CorrectA(var); _getch(); system("cls"); line(); cout << "7. Break statement is used for \n"; line(); cout << " a). Quit the current block b) Quit a program c) return 0 d) None \n"; CorrectA(var); _getch(); system("cls"); line(); cout << "8.int k=‘K’; cout << k ; will display \n"; line(); cout << " a) K b) ASCII code of K c) k d) garbage value \n"; CorrectB(var); _getch(); system("cls"); line(); cout << "9. The program that translates high-level language program into object code is called \n"; line(); cout << " a) Editor b) Assembler c) Decoder d) Compiler \n"; CorrectD(var); _getch(); system("cls"); line(); cout << "10. If you are required to declare a variable to store the marks of a student in OOP subject (Min 0~ Max 100), which data type will you choose to use the memory efficiently? \n"; line(); cout << " a) short b) unsigned int c) float d) int \n"; CorrectA(var); _getch(); system("cls"); line(); cout << "11. Switch selection structure can be used to represent any kind of if-else selection structure? \n"; line(); cout << " a) True b) False \n"; CorrectB(var); if (oop2_time == 100) { cout << "You have the remaining" << oop2_time << "seconds \n" << endl; Sleep(40000); } if (oop2_time == 60) { cout << "You have the remaining" << oop2_time << "seconds \n" << endl; Sleep(30000); } if (oop2_time == 30) { cout << "You have the remaining" << oop2_time << "seconds \n" << endl; Sleep(15000); } if (oop2_time == 15) { cout << "You have the remaining" << oop2_time << "seconds \n" << endl; Sleep(10000); } if (oop2_time == 5) { cout << "You have the remaining" << oop2_time << "seconds \n" << endl; Sleep(5000); cout << "\nTime is out\n"; goback(); intro(); } result("OOP2"); goback(); } }
0x01AA
А проблема/вопрос в чем?
Member 13780562
вопрос написан. Могу ли я запустить два процесса одновременно?
KarstenK
совет: используйте else в следующем if или переключатель (по умолчанию).