ahmed0saber

A pattern in C++

Nov 5th, 2020
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int n=7,m,a,s;
  6.     while(n>0)
  7.     {
  8.         a=7-n;
  9.         s=2*a;
  10.         m=n;
  11.         while(m>0)
  12.         {
  13.             cout<<" ";
  14.             m=m-1;
  15.         }
  16.         cout<<"+";
  17.         if(s>0)
  18.         {
  19.             while(s>1)
  20.             {
  21.                 cout<<" ";
  22.                 s=s-1;
  23.             }
  24.             cout<<"+";
  25.         }
  26.         cout<<endl;
  27.         n=n-1;
  28.     }
  29.     n=1;
  30.         while(n<7)
  31.     {
  32.         n=n+1;
  33.         a=7-n;
  34.         s=2*a;
  35.         m=n;
  36.         while(m>0)
  37.         {
  38.             cout<<" ";
  39.             m=m-1;
  40.         }
  41.         cout<<"+";
  42.         if(s>0)
  43.         {
  44.             while(s>1)
  45.             {
  46.                 cout<<" ";
  47.                 s=s-1;
  48.             }
  49.             cout<<"+";
  50.         }
  51.         cout<<endl;
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment