Advertisement
ULK

Лабораторная №9 (11.180)

ULK
Dec 6th, 2022
807
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int m;
  8.  
  9.     cout << "Enter the amount of elements: " << endl;
  10.     cin >> m;
  11.  
  12.     int i;
  13.     int j = 0;
  14.     int* a;
  15.     a = new int[m];
  16.  
  17.     cout << "Enter the elements: " << endl;
  18.     for (i = 0; i < m; i++) {
  19.         cin >> a[i];                //ввод чисел с клавиатуры
  20.     }
  21.     while (a[j] != 5) {
  22.         j++;
  23.     }
  24.     while (a[m] != 5) {
  25.         m--;
  26.     }
  27.     cout << "The first 5:    The last 5:" << endl;
  28.     cout << j + 1 << "               " << m + 1;
  29. }
  30.  
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement