Advertisement
Guest User

Untitled

a guest
May 6th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int v[30][30];
  5. int Elem[626];
  6. int indice;
  7.  
  8. int main()
  9. {
  10.  
  11. int N;
  12. cin >> N;
  13. for (int i=1;i<=N;i++)
  14. for (int j=1;j<=N;j++)
  15. cin >> v[i][j];
  16.  
  17. int sens=-1;
  18. for (int i=1;i<=N;i++)
  19. {
  20.  
  21. for (int j=1;j<=i;j++)
  22. if (sens == -1) Elem[++indice]=v[j][i-j+1];
  23. else Elem[++indice]=v[i-j+1][j];
  24.  
  25. sens=sens*-1;
  26. }
  27.  
  28. for (int i=2;i<=N;i++)
  29. {
  30. for (int j=i;j<=N;j++)
  31. if (sens == -1) Elem[++indice]=v[j][N-j+i];
  32. else Elem[++indice]=v[N-j+i][j];
  33.  
  34. sens=sens*-1;
  35. }
  36.  
  37. for (int i=1;i<=indice;i++) cout <<Elem[i] << " ";
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement