Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <utility>
- #include <map>
- #include <functional>
- #include "windows.h"
- using namespace std;
- void staining(string text, int color) {
- HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
- SetConsoleTextAttribute(hConsole, color);
- cout << text << endl;
- }
- void II() {
- system("cls");
- staining("Некорректный ввод!\nПопробуйте снова", 4);
- Sleep(2000);
- }
- static map<string, function<int(void)>> funcs = {
- {"func1",[]() {
- return 1;
- }},
- {"func2",[]() {
- return 2;
- }},
- {"func3",[]() {
- return 3;
- }},
- {"func4",[]() {
- return 3;
- }},
- {"func5",[]() {
- return 3;
- }},
- {"func6",[]() {
- return 3;
- }},
- {"func7",[]() {
- return 3;
- }},
- {"func8",[]() {
- return 3;
- }},
- {"func9",[]() {
- return 3;
- }},
- {"func10",[]() {
- return 3;
- }},
- {"func11",[]() {
- return 3;
- }},
- {"func12",[]() {
- return 3;
- }},
- {"func13",[]() {
- return 3;
- }},
- {"func14",[]() {
- return 3;
- }},
- {"func15",[]() {
- return 3;
- }},
- {"func16",[]() {
- return 3;
- }},
- {"func17",[]() {
- return 3;
- }}
- {"func18",[]() {
- return 3;
- }},
- {"func19",[]() {
- return 3;
- }},
- {"func20",[]() {
- return 3;
- }},
- {"func21",[]() {
- return 3;
- }},
- {"func22",[]() {
- return 3;
- }},
- {"func23",[]() {
- return 3;
- }},
- {"func24",[]() {
- return 3;
- }},
- {"func25
- ",[]() {
- return 3;
- }}
- };
- int main() {
- setlocale(0, "Russian");
- while (true) {
- system("cls");
- staining("Выберите вариант 1-25!", 3);
- string option;
- cin >> option;
- size_t found = option.find_first_not_of("1234567890");
- if (found == string::npos) {
- if (stoi(option) > 0 && stoi(option) < 26) {
- cout << funcs["func" + option]() << endl;
- }
- else {
- II();
- }
- }
- else {
- II();
- }
- }
- }
Add Comment
Please, Sign In to add comment