Advertisement
Guest User

#3

a guest
Oct 15th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     short unsigned int n;
  8.     cin >> n;
  9.     int array[n][n];
  10.  
  11.     //fill
  12.     for (int x = 0; x < n; x++) {
  13.         for (int y = 0; y < n; y++) {
  14.             array[x][y] = abs(y-x);
  15.         }
  16.     }
  17.    
  18.     //output
  19.     for (int x = 0; x < n; x++) {
  20.         for (int y = 0; y < n; y++) {
  21.             cout<<array[x][y]<<" ";
  22.         }
  23.         cout<<endl;
  24.     }
  25.  
  26.  
  27.     return 0;
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement