Advertisement
Tudor_Chender

varianta 89 2009

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