PhotoShaman

Laba3 Tasks

Nov 28th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.97 KB | None | 0 0
  1. --------------------------
  2. 1
  3.  
  4. #include <iostream>
  5. #include <clocale>
  6. #include <windows.h>
  7.  
  8. using namespace std;
  9.  
  10. static void SetCursorPosition(int x, int y)
  11. {
  12.     COORD coord;
  13.     coord.X = x;
  14.     coord.Y = y;
  15.     SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
  16. }
  17.  
  18. void main()
  19. {
  20.     setlocale(LC_ALL, "Russian");
  21.     system("mode con cols=80 lines=40");
  22.     int count = 0, mark, sum;
  23.  
  24.     for (int i = 0; i < 77; i++) cout << '-';
  25.     cout << "\nСтуденты: |";
  26.     for (int i = 1; i <= 15; i++) cout << " " << i << " |";
  27.     cout << endl;
  28.     for (int i = 0; i < 77; i++) cout << '-';
  29.  
  30.     for (int i = 1; i <= 4; i++)
  31.     {
  32.         if(i < 4) cout << endl << i << " предмет |";
  33.         else cout << endl << "Ср. балл  |";
  34.         for (int i = 1; i <= 15; i++)
  35.         {
  36.             if(i < 10) cout << "   |";
  37.             else cout << "    |";
  38.         }
  39.     }
  40.     cout << endl;
  41.     for (int i = 0; i < 77; i++) cout << '-';
  42.  
  43.     for (int i = 1; i <= 15; i++)
  44.     {
  45.         sum = 0;
  46.         bool whitoutBadMarks = true;
  47.         for (int j = 1; j <= 3; j++)
  48.         {
  49.             do
  50.             {
  51.                 SetCursorPosition(0, 9); cout << "         \n        \n         ";
  52.                 SetCursorPosition(0, 8);
  53.                 cout << "Введите оценку " << i << "-го студента по " << j << "-му предмету.    " << endl;
  54.                 cin >> mark;
  55.                 SetCursorPosition(0, 8);
  56.             } while (!(mark > 0 && mark < 6));
  57.             if (i < 10) SetCursorPosition(12 + (4 * (i - 1)), j + 2);
  58.             else SetCursorPosition(48 + (5 * (i - 10)), j + 2);
  59.             cout << mark;
  60.             if (mark <= 2) whitoutBadMarks = false;
  61.             sum += mark;
  62.         }
  63.         if (whitoutBadMarks) count++;
  64.         if (i < 10) SetCursorPosition(12 + (4 * (i - 1)), 6);
  65.         else SetCursorPosition(48 + (5 * (i - 10)), 6);
  66.         cout << sum / 3 << endl;
  67.     }
  68.     SetCursorPosition(0, 10);
  69.     cout << "Количество студентов без двоек: " << count << endl;
  70.     cout << "Нажмите ESC для выхода.";
  71.     while (true) if (GetAsyncKeyState(VK_ESCAPE)) break;
  72. }
  73.  
  74. ---------------------------
  75.  
  76. 2
  77.  
  78. /*Початковий внесок в банку рівний 1000 грн.Через кожен місяць розмір внеску
  79. збільшується на P відсотків від наявної суми(P дійсне число, 0 < P < 25).По даному P
  80.     визначити, через скільки місяців розмір внеску перевищить 1100 грн., і вивести знайдену
  81.     кількість місяців K(ціле число) і підсумковий розмір внеску S(дійсне число).*/
  82.  
  83. #include <iostream>
  84. #include <clocale>
  85.  
  86. using namespace std;
  87.  
  88. void main()
  89. {
  90.     setlocale(LC_ALL, "Russian");
  91.     int mounce = 0;
  92.     double persent, money = 1000;
  93.  
  94.     do
  95.     {
  96.         cout << "Введите процент(0 < P < 25): ";
  97.         cin >> persent;
  98.         system("cls");
  99.     }
  100.     while (!(persent > 0 && persent < 25));
  101.  
  102.     while (money < 1100)
  103.     {
  104.         mounce++;
  105.         money *= 1 + persent / 100;
  106.     }
  107.  
  108.     cout <<"Количество месяцев: " << mounce << endl;
  109.     cout << "Итоговая сумма: " << money << endl;
  110.  
  111.     system("pause");
  112. }
  113.  
  114.  
  115. -------------------------------
  116. 3
  117.  
  118. #include <iostream>
  119. #include <clocale>
  120. #include <windows.h>
  121.  
  122. using namespace std;
  123.  
  124. static void SetCursorPosition(int x, int y)
  125. {
  126.     COORD coord;
  127.     coord.X = x;
  128.     coord.Y = y;
  129.     SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
  130. }
  131.  
  132. void main()
  133. {
  134.     setlocale(LC_ALL, "Russian");
  135.     system("mode con cols=80 lines=40");
  136.     int heigth;
  137.  
  138.     do
  139.     {
  140.     system("cls");
  141.     cout << "Введите высоту полупирамиды: ";
  142.     cin >> heigth;
  143.     }while(!(heigth > 1 && heigth < 24));
  144.  
  145.     for(int y = 1; y <= heigth; y++)
  146.     {
  147.         SetCursorPosition(0, y + 3);
  148.         for(int j = 1; j < heigth - y + 1; j++ ) cout << ' ';
  149.         for(int a = 1; a < y + 2; a++ ) cout << '#';
  150.         cout << endl;
  151.     }
  152.     system("pause");
  153. }
  154.  
  155.  
  156.  
  157.  
  158. -------------------------------
  159. 4
  160.  
  161.  
  162. #include <iostream>
  163. #include <clocale>
  164. #include <windows.h>
  165.  
  166. using namespace std;
  167.  
  168. void main()
  169. {
  170.     setlocale(LC_ALL, "Russian");
  171.     system("mode con cols=80 lines=40");
  172.  
  173.     double credit;
  174.     int balance;
  175.     int _25cent = 0, _10cent = 0, _5cent = 0, _1cent = 0;
  176.  
  177.     do
  178.     {
  179.         system("cls");
  180.         cout << "Введите долг продавца(Например 9.75): ";
  181.         cin >> credit;
  182.     } while (credit < 0);
  183.  
  184.     balance = (int)(credit * 100);
  185.  
  186.     while (balance > 0)
  187.     {
  188.         if (balance >= 25)
  189.         {
  190.             balance -= 25;
  191.             _25cent++;
  192.         }
  193.         else if (balance >= 10)
  194.         {
  195.             balance -= 10;
  196.             _10cent++;
  197.         }
  198.         else if (balance >= 5)
  199.         {
  200.             balance -= 5;
  201.             _5cent++;
  202.         }
  203.         else if (balance >= 1)
  204.         {
  205.             balance -= 1;
  206.             _1cent++;
  207.         }
  208.     }
  209.  
  210.     cout << "\nВам выдали монеты номиналом:\n\n";
  211.     cout << "25 центов: " << _25cent << " шт.\n";
  212.     cout << "10 центов: " << _10cent << " шт.\n";
  213.     cout << "5  центов: " << _5cent << " шт.\n";
  214.     cout << "1  цент:   " << _1cent << " шт.\n";
  215.     system("pause");
  216. }
Advertisement
Add Comment
Please, Sign In to add comment