Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <tchar.h>
- #include <stdio.h>
- #include <conio.h>
- #include <windows.h>
- #include <iostream>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL, "Russian");
- unsigned int counter;
- bool exit = false;
- loop:
- while (!exit)
- {
- cout << " .................#########...............=##=..... " << endl; Sleep(30);
- cout << " ................##########-............########... " << endl; Sleep(30);
- cout << " .................#########............@#########.. " << endl; Sleep(30);
- cout << " ......#.........:#####.................0########.. " << endl; Sleep(30);
- cout << " ....#:........###.........................#####... " << endl; Sleep(30);
- cout << " _| _| ..0#........*###.................................. " << endl; Sleep(30);
- cout << " _|_| _|_| _|_| _|_|_| _| _| .##........####+.................................. " << endl; Sleep(30);
- cout << " _| _| _| _|_|_|_| _| _| _| _| *#@.......=####................................... " << endl; Sleep(30);
- cout << " _| _| _| _| _| _| _| ##........#####......+#####....................... " << endl; Sleep(30);
- cout << " _| _| _|_|_| _| _| _|_|_| ##.......-####@.....#######.......######.......#.. " << endl; Sleep(30);
- cout << " ##.......*#####.....######*......*#######......#.. " << endl; Sleep(30);
- cout << " ###.......#####0....#####..........######.....+#+. " << endl; Sleep(30);
- cout << " ______________ ####......#######..................@####......###. " << endl; Sleep(30);
- cout << " | | #####....##########.........................+####. " << endl; Sleep(30);
- cout << " |[1] Задачи | ######...##############...######:.........######=. " << endl; Sleep(30);
- cout << " | | ########.###############....@-....=#############.. " << endl; Sleep(30);
- cout << " |[2] Выход | ##########################0####=@###############.. " << endl; Sleep(30);
- cout << " |______________| *###########################*:##################.. " << endl; Sleep(30);
- cout << " .#############################0..##############... " << endl; Sleep(30);
- cout << " .:###########################-...:############*... " << endl; Sleep(30);
- cout << " ..=##########.###############....:############.... " << endl; Sleep(30);
- cout << " ....#########..##############+...@###########..... " << endl; Sleep(30);
- cout << " ......#######...#############@...###########...... " << endl; Sleep(30);
- cout << " .................*############...##########...#..# " << endl; Sleep(30);
- cout << " ...................############..#######.......-.. " << endl; Sleep(30);
- cout << "----------------------------------------------------------------------------------------------------------" << endl << endl << ">";
- cin >> counter;
- cout << endl;
- switch (counter)
- {
- case 1:
- {
- cout << endl << "Выберите интересующую вас задачу в следующем меню." << endl << endl; Sleep(30);
- while (!exit)
- {
- cout << "_______________________|Задачи|_______________________" << endl; Sleep(30);
- cout << "\n[1] Тема 'Разветвляющиеся алгоритмы'" << endl; Sleep(30);
- cout << "\n[2] Тема 'Массивы (динамическое выделение памяти)'" << endl; Sleep(30);
- cout << "\n[3] Тема 'Функции пользователя'" << endl; Sleep(30);
- cout << "\n[4] Задача №14" << endl; Sleep(30);
- cout << "\n[5] Задача №15" << endl; Sleep(30);
- cout << "\n[0] Вернуться в предыдущее меню" << endl << endl << ">"; Sleep(30);
- cin >> counter;
- cout << endl;
- switch (counter)
- {
- case 1:
- cout << "Разветвляющиеся алгоритмы:" << endl; Sleep(30);
- cout << endl;
- cout << "Условие задачи:" << endl; Sleep(30);
- cout << endl;
- cout << "Запишите условный оператор, в котором значение переменной с" << endl; Sleep(30);
- cout << "вычисдяется по формуле a+b,если а четное и a*b,если а - нечетное" << endl << endl; Sleep(30);
- cout << "\n[1]Вывести листинг программы" << endl; Sleep(30);
- cout << "\n[2]Запустить программу" << endl << endl << ">"; Sleep(30);
- cin >> counter;
- cout << endl;
- switch (counter)
- {
- case 1:
- cout << "#include <iostream> " << endl; Sleep(30);
- cout << "using namespace std; " << endl; Sleep(30);
- cout << "int main() { " << endl; Sleep(30);
- cout << " setlocale(LC_ALL, "ru"); "<< endl; Sleep(30);
- cout << " int a, b; " << endl; Sleep(30);
- cout << " cout << "Введите число а : " << endl; " << endl; Sleep(30);
- cout << " cin >> a; " << endl; Sleep(30);
- cout << " cout << "Введите число b : " << endl; " << endl; Sleep(30);
- cout << " cin >> b; " << endl; Sleep(30);
- cout << " if (a % 2 == 0) " << endl; Sleep(30);
- cout << " { " << endl; Sleep(30);
- cout << " cout << a + b << endl; " << endl; Sleep(30);
- cout << " } " << endl; Sleep(30);
- cout << " else " << endl; Sleep(30);
- cout << " { " << endl; Sleep(30);
- cout << " cout << a * b<< endl; " << endl; Sleep(30);
- cout << " } " << endl; Sleep(30);
- cout << "} " << endl; Sleep(30);
- break;
- case 2:
- ShellExecute(NULL, "open", "D:\\практика\\2\\Debug\\ConsoleApplication4.exe", NULL, NULL, SW_SHOWDEFAULT);
- }
- cout << endl;
- system("pause");
- cout << endl;
- break;
- case 2:
- cout << "Массивы (динамическое выделение памяти)" << endl; Sleep(30);
- cout << endl;
- cout << "Условие задачи:" << endl; Sleep(30);
- cout << endl;
- cout << "Ввести массив из n элементов и некоторое число P. " << endl; Sleep(30);
- cout << "Заменить все,большие Р,элементы массива этим числом" << endl; Sleep(30);
- cout << "Вычислить количество таких элемнтов.Если оно больше нуля,вывести преобразованный массив." << endl << endl; Sleep(30);
- cout << "\n[1]Вывести листинг программы" << endl; Sleep(30);
- cout << "\n[2]Запустить программу" << endl << endl << ">"; Sleep(30);
- cin >> counter;
- cout << endl;
- switch (counter)
- {
- case 1:
- cout << "#include "stdafx.h" " << endl; Sleep(30);
- cout << "#include <iostream> " << endl; Sleep(30);
- cout << "#include <cstdlib> " << endl; Sleep(30);
- cout << "#include <ctime> " << endl; Sleep(30);
- cout << "using namespace std; " << endl; Sleep(30);
- cout << " " << endl; Sleep(30);
- cout << "int main() " << endl; Sleep(30);
- cout << "{ " << endl; Sleep(30);
- cout << " int n, p, number; " << endl; Sleep(30);
- cout << " number = 0; " << endl; Sleep(30);
- cout << " cout << "Elements in array" << endl; " << endl; Sleep(30);
- cout << " cin >> n; " << endl; Sleep(30);
- cout << " cout << "Num" << endl; " << endl; Sleep(30);
- cout << " cin >> p; " << endl; Sleep(30);
- cout << " int* a = new int[n]; " << endl; Sleep(30);
- cout << " srand(time(NULL)); " << endl; Sleep(30);
- cout << " for (int i = 0; i < n; i++) " << endl; Sleep(30);
- cout << " { " << endl; Sleep(30);
- cout << " " << endl; Sleep(30);
- cout << " a[i] = 1 + (rand() % 100);; " << endl; Sleep(30);
- cout <<
- } "<<endl; Sleep(30);
- cout << " for (int i = 0; i < n; i++) " << endl; Sleep(30);
- cout << " { " << endl; Sleep(30);
- cout << " if (a[i]>p) " << endl; Sleep(30);
- cout << " { " << endl; Sleep(30);
- cout << " a[i] = p; " << endl; Sleep(30);
- cout << " number++; " << endl; Sleep(30);
- cout << " } " << endl; Sleep(30);
- cout << " } " << endl; Sleep(30);
- cout << " " << endl; Sleep(30);
- cout << " cout << "Number of elements>" << p << " = " << number << endl << "--------" << endl; " << endl; Sleep(30);
- cout << " if (number > 0) " << endl; Sleep(30);
- cout << " { " << endl; Sleep(30);
- cout << " for (int i = 0; i < n; i++) " << endl; Sleep(30);
- cout << " { " << endl; Sleep(30);
- cout << " cout << a[i] << endl; " << endl; Sleep(30);
- cout << " } " << endl; Sleep(30);
- cout << " } " << endl; Sleep(30);
- cout << "} " << endl; Sleep(30);
- break;
- case 2:
- ShellExecute(NULL, "open", "D:\\практика\\14\\Debug\\ConsoleApplication5.exe", NULL, NULL, SW_SHOWDEFAULT);
- }
- cout << endl;
- system("pause");
- cout << endl;
- break;
- case 3:
- cout << "Функции пользователя" << endl; Sleep(30);
- cout << " " << endl;
- cout << "Условие задачи:" << endl; Sleep(30);
- cout << " " << endl;
- cout << "Вычислить сумму факториалов всех нечетных чисел от m до n. " << endl; Sleep(30);
- cout << "Вычисление факториала оформить в функции." << endl << endl; Sleep(30);
- cout << "\n[1]Вывести листинг программы" << endl; Sleep(30);
- cout << "\n[2]Запустить программу" << endl << endl << ">"; Sleep(30);
- cin >> counter;
- cout << endl;
- switch (counter)
- {
- case 1:
- cout << "#include <iostream> " << endl; Sleep(30);
- cout << "#include <conio.h> " << endl; Sleep(30);
- cout << " " << endl; Sleep(30);
- cout << "using namespace std; " << endl; Sleep(30);
- cout << "int fact(int N) " << endl; Sleep(30);
- cout << "{ " << endl; Sleep(30);
- cout << " if (N < 0) " << endl; Sleep(30);
- cout << " return 0; " << endl; Sleep(30);
- cout << " if (N == 0) " << endl; Sleep(30);
- cout << " return 1; " << endl; Sleep(30);
- cout << " else " << endl; Sleep(30);
- cout << " return N * fact(N - 1); " << endl; Sleep(30);
- cout << "} " << endl; Sleep(30);
- cout << "int main() " << endl; Sleep(30);
- cout << "{ " << endl; Sleep(30);
- cout << " setlocale(LC_ALL, 'Russian'); " << endl; Sleep(30);
- cout << " int m, n; " << endl; Sleep(30);
- cout << " cout<<'Введите длину массива'<<endl; " << endl; Sleep(30);
- cout << " cin>>n; " << endl; Sleep(30);
- cout << " cout<<'С какого элемента считать сумму '<<endl; " << endl; Sleep(30);
- cout << " cout<<'факториалов нечетных чисел?'<<endl; " << endl; Sleep(30);
- cout << " cin>>m; " << endl; Sleep(30);
- cout << " int *arr = new int[n]; " << endl; Sleep(30);
- cout << " for (int i = 0; i <= n; i++) " << endl; Sleep(30);
- cout << " { " << endl; Sleep(30);
- cout << " arr[i] = i + 1; " << endl; Sleep(30);
- cout << " } " << endl; Sleep(30);
- cout << " int sum=0; " << endl; Sleep(30);
- cout << " for (int i = 0; i <= n; i++) " << endl; Sleep(30);
- cout << " { " << endl; Sleep(30);
- cout << " if (arr[i] % 2 != 0) " << endl; Sleep(30);
- cout << " { " << endl; Sleep(30);
- cout << " sum = sum + fact(arr[i]); " << endl; Sleep(30);
- cout << " } " << endl; Sleep(30);
- cout << " } " << endl; Sleep(30);
- cout << " cout<<'Сумма факториалов нечетных чисел = '<<sum<<endl;" << endl; Sleep(30);
- cout << "} " << endl; Sleep(30);
- break;
- case 2:
- ShellExecute(NULL, "open","D:\\практика\\5\\Source5.exe ", NULL, NULL, SW_SHOWDEFAULT);
- }
- cout << endl;
- system("pause");
- cout << endl;
- break;
- case 4:
- cout << "Задача №14" << endl; Sleep(30);
- cout << endl;
- cout << "Условие задачи:" << endl; Sleep(30);
- cout << endl;
- cout << "Среди введенных слов распечатать сначала те, которые начинаются " << endl; Sleep(30);
- cout << "и оканчиваются одной и той де буквой,а затем - все остальные " << endl; Sleep(30);
- cout << "(слова выводить по одному на строке) " << endl << endl; Sleep(30);
- cout << "\n[1]Вывести листинг программы" << endl; Sleep(30);
- cout << "\n[2]Запустить программу" << endl << endl << ">"; Sleep(30);
- cin >> counter;
- cout << endl;
- switch (counter)
- {
- case 1:
- cout << "#include <iostream> " << endl; Sleep(20);
- cout << "#include <fstream> " << endl; Sleep(20);
- cout << "#include <string> " << endl; Sleep(20);
- cout << "#include <sstream> " << endl; Sleep(20);
- cout << " " << endl; Sleep(20);
- cout << "using namespace std; " << endl; Sleep(20);
- cout << " " << endl; Sleep(20);
- cout << "void f14 (char *str) { " << endl; Sleep(20);
- cout << " char c; " << endl; Sleep(20);
- cout << " int ins_word = 1; " << endl; Sleep(20);
- cout << " " << endl; Sleep(20);
- cout << " char *frst_sym = str; " << endl; Sleep(20);
- cout << " char *last_spc; " << endl; Sleep(20);
- cout << " " << endl; Sleep(20);
- cout << "scan: " << endl; Sleep(20);
- cout << " c = *str; " << endl; Sleep(20);
- cout << " goto srv; " << endl; Sleep(20);
- cout << " " << endl; Sleep(20);
- cout << "srv: " << endl; Sleep(20);
- cout << " if ( (c == ' ') || (c == '\0')) { " << endl; Sleep(20);
- cout << " if (ins_word == 1) { " << endl; Sleep(20);
- cout << " last_spc = str; " << endl; Sleep(20);
- cout << " ins_word = 0; " << endl; Sleep(20);
- cout << " str++; " << endl; Sleep(20);
- cout << " goto print; " << endl; Sleep(20);
- cout << " } " << endl; Sleep(20);
- cout << " str++; " << endl; Sleep(20);
- cout << " goto scan; " << endl; Sleep(20);
- cout << " } " << endl; Sleep(20);
- cout << " else { " << endl; Sleep(20);
- cout << " if (ins_word == 0) { " << endl; Sleep(20);
- cout << " frst_sym = str; " << endl; Sleep(20);
- cout << " ins_word = 1; " << endl; Sleep(20);
- cout << " } " << endl; Sleep(20);
- cout << " str++; " << endl; Sleep(20);
- cout << " goto scan; " << endl; Sleep(20);
- cout << " } " << endl; Sleep(20);
- cout << " " << endl; Sleep(20);
- cout << "print: " << endl; Sleep(20);
- cout << " if (*(last_spc - 1) == *frst_sym) { " << endl; Sleep(20);
- cout << " for ( ; frst_sym != last_spc; frst_sym++) {" << endl; Sleep(20);
- cout << " std::cout<<*frst_sym; " << endl; Sleep(20);
- cout << " } " << endl; Sleep(20);
- cout << " std::cout<<'\n'; " << endl; Sleep(20);
- cout << " } " << endl; Sleep(20);
- cout << " if (c == '\0') " << endl; Sleep(20);
- cout << " return; " << endl; Sleep(20);
- cout << " goto scan; " << endl; Sleep(20);
- cout << "} " << endl; Sleep(20);
- cout << " " << endl; Sleep(20);
- cout << "void f14_1 (char *str) { " << endl; Sleep(20);
- cout << " char c; " << endl; Sleep(20);
- cout << " int ins_word = 1; " << endl; Sleep(20);
- cout << " " << endl; Sleep(20);
- cout << " char *frst_sym = str; " << endl; Sleep(20);
- cout << " char *last_spc; " << endl; Sleep(20);
- cout << " " << endl; Sleep(20);
- cout << "scan: " << endl; Sleep(20);
- cout << " c = *str; " << endl; Sleep(20);
- cout << " goto srv; " << endl; Sleep(20);
- cout << " " << endl; Sleep(20);
- cout << "srv: " << endl; Sleep(20);
- cout << " if ( (c == ' ') || (c == '\0')) { " << endl; Sleep(20);
- cout << " if (ins_word == 1) { " << endl; Sleep(20);
- cout << " last_spc = str; " << endl; Sleep(20);
- cout << " ins_word = 0; " << endl; Sleep(20);
- cout << " str++; " << endl; Sleep(20);
- cout << " goto print; " << endl; Sleep(20);
- cout << " } " << endl; Sleep(20);
- cout << " str++; " << endl; Sleep(20);
- cout << " goto scan; " << endl; Sleep(20);
- cout << " } " << endl; Sleep(20);
- cout << " else { " << endl; Sleep(20);
- cout << " if (ins_word == 0) { " << endl; Sleep(20);
- cout << " frst_sym = str; " << endl; Sleep(20);
- cout << " ins_word = 1; " << endl; Sleep(20);
- cout << " } " << endl; Sleep(20);
- cout << " str++; " << endl; Sleep(20);
- cout << " goto scan; " << endl; Sleep(20);
- cout << " } " << endl; Sleep(20);
- cout << " " << endl; Sleep(20);
- cout << "print: " << endl; Sleep(20);
- cout << " if (*(last_spc - 1) != *frst_sym) { " << endl; Sleep(20);
- cout << " for ( ; frst_sym != last_spc; frst_sym++) " << endl; Sleep(20);
- cout << " {std::cout<<*frst_sym; } " << endl; Sleep(20);
- cout << " std::cout<<'\n'; " << endl; Sleep(20);
- cout << " } " << endl; Sleep(20);
- cout << " if (c == '\0') " << endl; Sleep(20);
- cout << " return; " << endl; Sleep(20);
- cout << " goto scan; " << endl; Sleep(20);
- cout << "} " << endl; Sleep(20);
- cout << " " << endl; Sleep(20);
- cout << " " << endl; Sleep(20);
- cout << "int main (void) { " << endl; Sleep(20);
- cout << " char s[]='ada dds ada dds'; " << endl; Sleep(20);
- cout << " f14 (s); " << endl; Sleep(20);
- cout << " f14_1 (s); " << endl; Sleep(20);
- cout << " return 0; " << endl; Sleep(20);
- cout << "} " << endl; Sleep(20);
- break;
- case 2:
- ShellExecute(NULL, "open", "D:\\практика\\14.1\\main.exe", NULL, NULL, SW_SHOWDEFAULT);
- }
- cout << endl;
- system("pause");
- cout << endl;
- break;
- case 5:
- cout << "Задача №15" << endl; Sleep(30);
- cout << endl;
- cout << "Условие задачи:" << endl; Sleep(30);
- cout << endl;
- cout << "В файле содержится список слов. Распечатать те из них, которые " << endl; Sleep(30);
- cout << "начинаются и оканчиваются одной и той же буквой" << endl << endl; Sleep(30);
- cout << "\n[1]Вывести листинг программы" << endl; Sleep(30);
- cout << "\n[2]Запустить программу" << endl << endl << ">"; Sleep(30);
- cin >> counter;
- cout << endl;
- switch (counter)
- {
- case 1:
- cout << "#include <iostream> " << endl; Sleep(30);
- cout << "#include <fstream> " << endl; Sleep(30);
- cout << "#include <string> " << endl; Sleep(30);
- cout << "#include <sstream> " << endl; Sleep(30);
- cout << " " << endl; Sleep(30);
- cout << "using namespace std; " << endl; Sleep(30);
- cout << " " << endl; Sleep(30);
- cout << "int main() " << endl; Sleep(30);
- cout << "{ " << endl; Sleep(30);
- cout << "string s; " << endl; Sleep(30);
- cout << "ifstream F; " << endl; Sleep(30);
- cout << "F.open('D:\\Практика\\Задания\\15\\111.txt', ios::in);" << endl; Sleep(30);
- cout << " " << endl; Sleep(30);
- cout << "getline(F, s); " << endl; Sleep(30);
- cout << "cout << s << endl<<endl; " << endl; Sleep(30);
- cout << "stringstream strm(s); " << endl; Sleep(30);
- cout << "for (string i; strm >> i;) " << endl; Sleep(30);
- cout << " if (i[0] == i[i.length() - 1]) " << endl; Sleep(30);
- cout << " cout << i << endl; " << endl; Sleep(30);
- cout << "return 0; " << endl; Sleep(30);
- cout << "} " << endl; Sleep(30);
- break;
- case 2:
- ShellExecute(NULL, "open", "D:\\практика\\15\\Source.exe", NULL, NULL, SW_SHOWDEFAULT);
- }
- cout << endl;
- system("pause");
- cout << endl;
- break;
- case 0:
- goto loop;
- }
- }
- }
- case 2:
- {
- exit = true;
- cout << endl << "Нажмите любую кнопку для выхода из программы" << endl;
- break;
- }
- }
- }
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement