Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- ifstream fin("detdrum1.in");
- ofstream fout("detdrum1.out");
- int n, a[105], k;
- void Citire()
- {
- fin >> n >> k;
- for(int i = 1; i <= n; i++)
- fin >> a[i];
- }
- void Rezolvare(int b)
- {
- if(a[b]) Rezolvare(a[b]);
- fout << b << " ";
- }
- int main()
- {
- Citire();
- Rezolvare(k);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment