daily pastebin goal
23%
SHARE
TWEET

Untitled

a guest Mar 26th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long ll;
  5.  
  6. #define sc1(a) scanf("%lld",&a)
  7. #define sc2(a,b) scanf("%lld %lld",&a,&b)
  8.  
  9. #define pf1(a) printf("%lld\n",a)
  10. #define pf2(a,b) printf("%lld %lld\n",a,b)
  11.  
  12. #define mx 100005
  13. #define mod 10000007
  14. #define Accepted 0
  15.  
  16. int main()
  17. {
  18.     int n;
  19.     scanf("%d", &n);
  20.  
  21.     int a[n][n], x = 0;
  22.  
  23.     for(int i = 0; i<2*n-1; ++i)
  24.     {
  25.         for(int r = 0; r<=i && r<n; ++r)
  26.         {
  27.             int c = i-r;
  28.             if(c>=0 && c<n)
  29.                 a[r][c] = ++x;
  30.         }
  31.     }
  32.  
  33.  
  34.     for (int i = 0; i < n; ++i)
  35.     {
  36.         for (int j = n-1; j >= 0; --j)
  37.         {
  38.             printf("%d ", a[i][j]);
  39.         }
  40.  
  41.         printf("\n");
  42.     }
  43.  
  44.     return Accepted;
  45. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top