netx_iit

Pattern Program 2

Jul 15th, 2020 (edited)
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. /*pattern program
  2. 1 1 1 1 1
  3. 1 2 2 2 1
  4. 1 2 3 2 1
  5. 1 2 2 2 1
  6. 1 1 1 1 1
  7. */
  8. #include<iostream>
  9. using namespace std;
  10. int main()
  11. {
  12.     int i=1,j=1,k=0,ans=1;
  13.     for(i=1;i<=5;i++)
  14.     {
  15.         for(j=1;j<=5;j++)
  16.         {
  17.             //cout<<" "<<j+k;
  18.             if(i==1 || i==5 || j==1 || j==5 )
  19.             {
  20.                 cout<<"1";
  21.             }
  22.             else if(i==3 && j==3)
  23.             {
  24.                 cout<<"3";
  25.             }
  26.             else
  27.             {
  28.                 cout<<"2";
  29.             }
  30.         }
  31.         cout<<"\n";
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment