PhotoShaman

Untitled

Dec 18th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.62 KB | None | 0 0
  1. #include <iostream>
  2. #include <clocale>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. void vvod(int *A, int *B, int n);
  8.  
  9. void vivod(int *A, int *B, int *C, int n);
  10.  
  11. void SeriesVictories(int *A, int *B, int *C, int n);
  12.  
  13. int main()
  14. {
  15.     setlocale(LC_ALL, "Russian");
  16.     int A[20], B[20], C[20];
  17.  
  18.     vvod(A, B, 20);
  19.  
  20.     SeriesVictories(A, B, C, 20);
  21.  
  22.     vivod(A, B, C, 20);
  23.    
  24.     cin.get(); cin.get();
  25. }
  26.  
  27. void vvod(int *A, int *B, int n) //Ввод элементов массивов А и В
  28. {
  29.     for (int i = 0; i < n; i++)
  30.     {
  31.         cout << "Игра №" << i + 1 << endl;
  32.         cout << "Забито: ";    cin >> A[i];
  33.         cout << "Пропущено: "; cin >> B[i]; cout << endl;
  34.     }
  35. }
  36.  
  37. void SeriesVictories(int *A, int *B, int *C, int n)
  38. {
  39.     int SerVic = 0, MaxSerVic = 0; //Счетчик серии побед и максимальная серия побед
  40.     for (int i = 0; i < n; i++)
  41.     {
  42.         if (A[i] > B[i])
  43.         {
  44.             SerVic++;
  45.         }
  46.         else
  47.         {
  48.             SerVic = 0;
  49.         }
  50.         if (SerVic > MaxSerVic)
  51.         {
  52.             MaxSerVic = SerVic;
  53.             for (int j = 0; j < MaxSerVic; j++)
  54.             {
  55.                 C[j] = i + j + 2 - MaxSerVic;
  56.             }
  57.             for (int j = MaxSerVic; j < n; j++)
  58.             {
  59.                 C[j] = 0;
  60.             }
  61.         }
  62.     }
  63. }
  64.  
  65. void vivod(int *A, int *B, int *C, int n) //Вывод элементов массивов А, В и С
  66. {
  67.     system("cls");
  68.     cout << "Массив А";
  69.     for (int i = 0; i < n; i++)
  70.     {
  71.         cout << setw(3) << A[i];
  72.     }
  73.     cout << endl;
  74.  
  75.     cout << "Массив B";
  76.     for (int i = 0; i < n; i++)
  77.     {
  78.         cout << setw(3) << B[i];
  79.     }
  80.     cout << endl;
  81.  
  82.     cout << "Массив C";
  83.     for (int i = 0; i < n; i++)
  84.     {
  85.         cout << setw(3) << C[i];
  86.     }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment