AlexandruT

[pbInfo] detdrum1

Dec 4th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <fstream>
  2.  
  3. using namespace std;
  4.  
  5. ifstream fin("detdrum1.in");
  6. ofstream fout("detdrum1.out");
  7.  
  8. int n, a[105], k;
  9.  
  10. void Citire()
  11. {
  12.     fin >> n >> k;
  13.     for(int i = 1; i <= n; i++)
  14.         fin >> a[i];
  15. }
  16.  
  17. void Rezolvare(int b)
  18. {
  19.     if(a[b]) Rezolvare(a[b]);
  20.     fout << b << " ";
  21. }
  22.  
  23. int main()
  24. {
  25.     Citire();
  26.     Rezolvare(k);
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment