fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4. int a[10];
  5. int n, i;
  6. cout<<"n:";
  7. cin>>n;
  8. for (i=0; i<n; ++i) cin>>a[i];
  9. {
  10. // Нечетные
  11. for (i=1; i<n; i+=2)
  12. cout<<a[i]<<" "<<"\t";
  13. cout << endl;
  14. // Четные
  15. for (i= ((n-1)/2)*2; i>= 0; i-=2)
  16. cout<<a[i]<<" "<<"\t";
  17. cout << endl;
  18. }
  19. return 0;
  20. }
Success #stdin #stdout 0s 4484KB
stdin
12
0
1
2
3
4
5
6
7
8
9
10
11
stdout
n:1 	3 	5 	7 	9 	11 	
10 	8 	6 	4 	2 	0