Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <clocale>
- #include <iomanip>
- using namespace std;
- void vvod(int *A, int *B, int n);
- void vivod(int *A, int *B, int *C, int n);
- void SeriesVictories(int *A, int *B, int *C, int n);
- int main()
- {
- setlocale(LC_ALL, "Russian");
- int A[20], B[20], C[20];
- vvod(A, B, 20);
- SeriesVictories(A, B, C, 20);
- vivod(A, B, C, 20);
- cin.get(); cin.get();
- }
- void vvod(int *A, int *B, int n) //Ввод элементов массивов А и В
- {
- for (int i = 0; i < n; i++)
- {
- cout << "Игра №" << i + 1 << endl;
- cout << "Забито: "; cin >> A[i];
- cout << "Пропущено: "; cin >> B[i]; cout << endl;
- }
- }
- void SeriesVictories(int *A, int *B, int *C, int n)
- {
- int SerVic = 0, MaxSerVic = 0; //Счетчик серии побед и максимальная серия побед
- for (int i = 0; i < n; i++)
- {
- if (A[i] > B[i])
- {
- SerVic++;
- }
- else
- {
- SerVic = 0;
- }
- if (SerVic > MaxSerVic)
- {
- MaxSerVic = SerVic;
- for (int j = 0; j < MaxSerVic; j++)
- {
- C[j] = i + j + 2 - MaxSerVic;
- }
- for (int j = MaxSerVic; j < n; j++)
- {
- C[j] = 0;
- }
- }
- }
- }
- void vivod(int *A, int *B, int *C, int n) //Вывод элементов массивов А, В и С
- {
- system("cls");
- cout << "Массив А";
- for (int i = 0; i < n; i++)
- {
- cout << setw(3) << A[i];
- }
- cout << endl;
- cout << "Массив B";
- for (int i = 0; i < n; i++)
- {
- cout << setw(3) << B[i];
- }
- cout << endl;
- cout << "Массив C";
- for (int i = 0; i < n; i++)
- {
- cout << setw(3) << C[i];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment