fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int a[5];
  7. a[0] = 4; a[1] = 3; a[2] = 1; a[3] = 2; a[4] = 0;
  8. char z[5] = {0};
  9. for (int i=0; i < 5;z[i]++,z[i]<2?i=a[i]:i++)
  10. cout << (z[i]? "\n":to_string(i) + " ");
  11.  
  12. return 0;
  13. }
Success #stdin #stdout 0s 4364KB
stdin
Standard input is empty
stdout
0 4 
1 3 2