Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<vector>
- using namespace std;
- void rec(vector<int> a , vector<int> b, int i, int key){
- if(i >= a.size())
- return;
- if(a[i] == key)
- b.push_back(i);
- //return rec(a, b, i + 1, key);
- rec(a, b, i + 1, key);
- return;
- }
- int main() {
- int n;
- cin>>n;
- vector<int> a(n);
- vector<int > b;
- for(int i = 0; i < n; i++)
- cin>>a[i];
- int key;
- cin>>key;
- rec(a, b, 0, key);
- for(int i = 0; i < b.size(); i++)
- cout<<b[i]<<" ";
- return 0;
- }
Add Comment
Please, Sign In to add comment