Advertisement
Polnochniy

Untitled

Nov 14th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <vector>
  4. using namespace std;
  5. int main()
  6. {
  7. setlocale(LC_ALL, "Rus");
  8. int N;
  9. cout << "Введите число элементов " << endl;
  10. cin >> N;
  11. vector<int> a(N);
  12. cout << "Введите элементы массива . Найти четные индексы" << endl;
  13. for (int i = 0; i < N; i++)
  14. {
  15. cin >> a[i];
  16. }
  17. for (int chet_i : a)
  18. {
  19. if (chet_i % 2 == 0)
  20. {
  21. cout << "Номер четных индексов " << chet_i << " ";
  22. cout << "А сами элементы " << a[chet_i] << " " << endl;
  23. }
  24. }
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement