Advertisement
TheRasVa

Задача 5,4

Mar 29th, 2015
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. using namespace std;
  4.  
  5.  
  6. int main()
  7. {
  8.     int knowledge[10], cheating[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, i = 0;
  9.     setlocale(LC_ALL, "russian");
  10.     while (i < 10)
  11.     {
  12.         cin >> knowledge[i];
  13.         i++;
  14.     }
  15.     cout << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" << endl;
  16.     i = 0;
  17.     if (knowledge[0] < knowledge[1] && cheating[1] == 0)
  18.     {
  19.         cheating[0] = 1;
  20.         cout << knowledge[1] << endl;
  21.     }
  22.     else
  23.     {
  24.         cout << knowledge[0] << endl;
  25.     }
  26.     i++;
  27.     while (i < 9)
  28.     {
  29.         if (knowledge[i] < knowledge[i - 1] && knowledge[i - 1] > knowledge[i + 1] && cheating == 0)
  30.         {
  31.             cheating[i] = 1;
  32.             cout << knowledge[i - 1] << endl;
  33.         }
  34.         else
  35.         {
  36.             if (knowledge[i] < knowledge[i + 1] && knowledge[i + 1] > knowledge[i - 1] && cheating[i + 1] == 0)
  37.             {
  38.                 cheating[i] = 1;
  39.                 cout << knowledge[i + 1] << endl;
  40.             }
  41.             else
  42.             {
  43.                 cout << knowledge[i] << endl;
  44.             }
  45.         }
  46.         i++;
  47.     }
  48.     if (knowledge[9] < knowledge[8] && cheating[8] == 0)
  49.     {
  50.         cheating[9] = 1;
  51.         cout << knowledge[8] << endl;
  52.     }
  53.     else
  54.     {
  55.         cout << knowledge[9] << endl;
  56.     }
  57.     system("pause");
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement