🟢 Վարժություն 25

Գրել ծրագիր, որը կտպի տրված զանգվածի մեջտեղի էլեմենտը։ Եթե զանգվածը ունի զույգ թվով էլեմենտներ, ապա հարկավոր է տպել մեջտեղի 2 էլեմենտները անջատված բացատով։ Օրինակ՝ {5, 2, 3, 1} զանգվածի դեպքում հարկավոր է տպել 2 3։
#include <iostream>
#include <vector>
int main() {
  std::vector<int> arr;
  int size;
  std::cout << "Insert vector size ";
  std::cin >> size;
  std::cout << size << std::endl;;
  std::cout << "Insert vector elements: ";
  for (int i = 0; i < size; ++i) {
     int in;
     std::cin >> in;
     arr.push_back(in);
  }
  for (int i = 0; i < arr.size(); ++i) {
      std::cout << arr[i] << " ";
  }
  std::cout << std::endl;
  // put your code here
}
 

Constraints

Time limit: 0.2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue