Advertisement
Nusrat_Ullah

Timus 1319

Oct 25th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3. #include<algorithm>
  4. using namespace std;
  5. int main()
  6. {
  7.     int x=1,a,b,i,j;
  8.     scanf("%d",&a);
  9.     int ax[a+3][a+3];
  10.     for(j=a-1;j>=0;j--) for(b=j,i=0;b<a;i++,b++) ax[i][b]=x++;
  11.     for(i=1;i<a;i++) for(b=i,j=0;b<a;b++,j++) ax[b][j]=x++;
  12.     for(i=0;i<a;i++){
  13.         for(j=0;j<a;j++)printf("%d ",ax[i][j]);
  14.         printf("\n");
  15.     }
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement