Untitled

mail@pastecode.io avatar
unknown
c_cpp
8 months ago
588 B
0
Indexable
Never
#include <iostream>
#include <string>
#include <vector>


void foo(const std::vector<int> &old, std::vector<int> &n,int a, int b) {
    
    for (int i = a - 1; i <= b - 1; i++) {
        n[i - (a - 1)] = old[i];
    }

}

int main()
{
    std::vector<int> old;
    int a, b,N,c;
    std::cin >> N;
    for (int i = 0; i < N; i++) {
        std::cin >> c;
        old.push_back(c);
    }
    std::cin >> a >> b;
    std::vector<int> n(b - a + 1, 0);
    foo(old, n, a, b);
    for (int i = 0; i < b - a + 1; i++) {
        std::cout << n[i] << " ";
    }
}

Leave a Comment