Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <fstream>
  4. #include "determinant.h"
  5. #include "size.h"
  6. #include "matrix.h"
  7. #include "triangle.h"
  8. #include "area.h"
  9. #include "unitMatrix.h"
  10. #include "Windows.h"
  11. #include <string>
  12. #include <vector>
  13.  
  14. using namespace std;
  15.  
  16. int main_menu();
  17.  
  18.  
  19. int main()
  20. {
  21.     setlocale(LC_ALL, "Russian");
  22.    
  23.     main_menu();
  24.    
  25.    
  26.    
  27.     system("pause");
  28.     return 0;
  29. }
  30.  
  31. int main_menu()
  32. {
  33.     setlocale(LC_ALL, "Russian");
  34.     SetConsoleCP(1251); // Ввод с консоли в кодировке 1251
  35.     SetConsoleOutputCP(1251);   const string eng = "eng_menu.txt";
  36.     const string rus = "rus_menu.txt";
  37.     const string temp = "temp.txt";
  38.     char ch;
  39.     BOOL bFile;
  40.  
  41.     ifstream file_eng(eng);
  42.     ifstream file_rus(rus);
  43.     ofstream file_temp(temp);
  44.  
  45.     bool lang = 1;
  46.  
  47.     int key1, key2, row, column;
  48.     double determ, area2;
  49.     string mas_cap[35][35];
  50.  
  51.  
  52.     string str;
  53.     int i = 0;
  54.     vector<string> lines;
  55.     lines.reserve(14);
  56.     string line; while (getline(file_eng, line, '\n')) {
  57.         lines.push_back(line);
  58.     }
  59.    
  60.         do
  61.         {
  62.  
  63.             cout << lines.at(0) << endl;
  64.             cout << lines.at(1)<< endl;
  65.             cout << lines.at(2) << endl;
  66.             cout << lines.at(3) << endl;
  67.             cout << lines.at(4) << endl;
  68.             cout << lines.at(5) << endl;
  69.             cout << lines.at(6) << endl;
  70.             cout << lines.at(7) << endl;
  71.             key1 = _getch();
  72.             switch (key1)
  73.             {
  74.             case '1': {
  75.                 cout << lines.at(8) << endl;
  76.                 cin >> row >> column;
  77.  
  78.                 Matrix matrix(row, column);
  79.  
  80.                 matrix.init();
  81.                 matrix.display_elements();
  82.                 break;
  83.             }
  84.             case '2':
  85.             {
  86.                 TriangleMatrix trmatrix;
  87.                 trmatrix.init();
  88.                 trmatrix.display_elements();
  89.                 break;
  90.             }
  91.             case '3':
  92.             {
  93.                 cout << lines.at(8) << endl;
  94.                 cin >> row >> column;
  95.                 Determinant det(row, column);
  96.                 det.init();
  97.                 determ = det.getDeterm();
  98.                 cout << determ << endl;
  99.                 break;
  100.             }
  101.             case '4':
  102.             {
  103.                 Area area;
  104.                 area.init();
  105.  
  106.                 cout << lines.at(9) << area.getArea() << endl;
  107.                 break;
  108.             }
  109.             case '5':
  110.             {
  111.                 unitMatrix unit;
  112.                 unit.init();
  113.                 unit.TriangleMatrix::display_elements();
  114.                 break;
  115.             }
  116.             case '6':
  117.             {
  118.                 cout << lines.at(10) << endl;
  119.                 cin >> row >> column;
  120.                 Matrix obj1(row, column);
  121.                 obj1.init();
  122.                 cout << lines.at(11) << endl;
  123.                 cin >> row >> column;
  124.                 Matrix obj2(row, column);
  125.                 obj2.init();
  126.                 Matrix result;
  127.                 result = result.multiple(obj1, obj2);
  128.                 result.display_elements();
  129.  
  130.                 break;
  131.             }
  132.             case '7':
  133.             {
  134.  
  135.                 file_eng.open(eng, ios_base::in);
  136.                 file_rus.open(rus, ios_base::in);
  137.                 file_temp.open(temp);
  138.  
  139.                 if (lang)
  140.                 {
  141.                     lang = false;
  142.                     bFile = CopyFile(
  143.                         L"E:\\projects\\kursach\\kurs\\eng_menu.txt",
  144.                         L"E:\\projects\\kursach\\kurs\\temp_menu.txt",
  145.                         FALSE);
  146.                     if (bFile == FALSE)
  147.                     {
  148.                         cout << GetLastError() << endl;
  149.                     }
  150.                     else
  151.                         cout << lines.at(12) << endl;
  152.                
  153.                    
  154.                    
  155.                    
  156.                     i = 0;
  157.                     while (getline(file_eng, line, '\n')) {
  158.                         lines[i] = line;
  159.                         i++;
  160.                     }
  161.  
  162.                 }
  163.  
  164.                 else
  165.                 {
  166.                     lang = true;
  167.                     bFile = CopyFile(
  168.                         L"E:\\projects\\kursach\\kurs\\rus_menu.txt",
  169.                         L"E:\\projects\\kursach\\kurs\\temp_menu.txt",
  170.                         FALSE);
  171.                     if (bFile == FALSE)
  172.                     {
  173.                         cout << GetLastError() << endl;
  174.                     }
  175.                     else
  176.                         cout << lines.at(12)<< endl;
  177.                    
  178.                    
  179.                     i = 0;
  180.                
  181.                     while (getline(file_rus, line, '\n')) {
  182.                         lines[i] = line;                       
  183.                         i++;
  184.  
  185.                     }
  186.  
  187.  
  188.  
  189.                 }
  190.  
  191.                 file_eng.close();
  192.                 file_rus.close();
  193.                 file_temp.close();
  194.                 break;
  195.             }
  196.             default:
  197.  
  198.                 break;
  199.             }
  200.  
  201.         } while (key1 != 27);
  202.         return 0;
  203.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement