Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "windows.h"
- #include <vector>
- #include <string>
- #include <conio.h>
- using namespace std;
- HANDLE hCon = GetStdHandle(STD_OUTPUT_HANDLE);
- #define WIDTH 80
- #define HEIGHT 30
- void MainGet();
- int main()
- {
- string resize = "mode "+ to_string(WIDTH)+ ", "+ to_string(HEIGHT);
- system(resize.c_str());
- MainGet();
- }
- void print(const char text[], int x, int y)
- {
- COORD pos;
- pos.X = x;
- pos.Y = y;
- SetConsoleCursorPosition(hCon, pos);
- cout << text;
- }
- void MenuShow(int nomber)
- {
- vector <string> points = {"sin", "cos", "simple function"};
- system("cls");
- int xMiddle = WIDTH / 2;
- int yPart = HEIGHT / (points.size() + 1);
- for (int i = 1; i <= points.size(); i++)
- {
- if (i == nomber)
- {
- string temp = "<<" + points[i - 1] + ">>";
- print(temp.c_str(), xMiddle - temp.length() / 2, yPart*i);
- }
- else
- print(points[i-1].c_str(), xMiddle - points[i - 1].length() / 2, yPart*i);
- }
- }
- void MainGet()
- {
- int mode = 0; // 0 - menu, 1 - count get
- int menu_point = 1;
- MenuShow(menu_point);
- while (true)
- {
- int choice = _getch();
- if (!mode)
- {
- switch (choice)
- {
- case 72:
- menu_point = menu_point == 1 ? menu_point = 3 : menu_point - 1;
- break;
- case 80:
- menu_point = menu_point == 3 ? menu_point = 1 : menu_point + 1;
- break;
- }
- MenuShow(menu_point);
- }
- else
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment