Advertisement
Cucura_Georgiana

Varianta 18, Subiect 2

Nov 27th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.52 KB | None | 0 0
  1. 5.  #include<iostream>
  2. using namespace std;
  3. int a[1001][1001];
  4. int main()
  5. {
  6.     int i, j, n;
  7.     cin>>n;
  8.     for(i=1; i<=n; i++)
  9.     {
  10.         for(j=1; j<=n; j++)
  11.         {
  12.             if(i%2!=0)
  13.             {
  14.                 a[i][j]=i;
  15.             }
  16.             if(i%2==0)
  17.             {
  18.                 a[i][j]=j;
  19.             }
  20.         }
  21.     }
  22.     for(i=1; i<=n; i++)
  23.     {
  24.         for(j=1; j<=n; j++)
  25.         {
  26.             cout<<a[i][j]<<" ";
  27.         }
  28.         cout<<'\n';
  29.     }
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement