Advertisement
3nriched

Untitled

Mar 16th, 2011
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.76 KB | None | 0 0
  1. // again.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. using namespace std;
  7.  
  8. int _tmain(int argc, _TCHAR* argv[])
  9. {
  10.   int i=0, j=0, totallength=0, totalwidth=0, northsouthtriangleheight=0, northsouthtrianglebase=0,
  11.       eastwesttriangleheight=0, eastwesttrianglebase=0, squarecenter=5, limit1=0, limit2=0;  //declaration
  12.    
  13.     cout<<"enter totallength of flower";                            //user inputs the total length
  14.      cin>>totallength;                                              //variable stores it
  15.  
  16.      cout<<"enter totalwidth of flower";
  17.        cin>>totalwidth;
  18.                                                                        
  19.  
  20.      
  21.      northsouthtriangleheight=(totallength-squarecenter)/2;                  // computing triangleheight and trianglebase
  22.      northsouthtrianglebase=((northsouthtriangleheight*2)-1);
  23.  
  24.      eastwesttriangleheight=((totalwidth-squarecenter)/2);
  25.      eastwesttrianglebase=((eastwesttriangleheight*2)-1);
  26.      limit1=(eastwesttriangleheight+(northsouthtrianglebase/2)+1);
  27.      limit2=(eastwesttriangleheight+(northsouthtrianglebase/2)+1);
  28.  
  29.  
  30.       if(northsouthtriangleheight%2==0)
  31.        {
  32.            i=0, j=1;
  33.        }
  34.       else if(northsouthtriangleheight%2==1)
  35.        {
  36.            i=1, j=1;
  37.        }
  38.  
  39.          while(i<=northsouthtriangleheight)
  40.           {
  41.  
  42.             j=1;
  43.             while(j<=totalwidth)
  44.              {
  45.               if(j<=eastwesttriangleheight)
  46.                {
  47.                    cout<<" ";
  48.                }
  49.               else if(j>eastwesttriangleheight&&j<limit1)
  50.                 {
  51.                     cout<<" ";
  52.                 }
  53.               else if((j>=limit1)&&(j<=limit2))
  54.                 {
  55.                     cout<<"*";
  56.                 }
  57.               else if(j>limit2&&j<=totalwidth)
  58.               {
  59.                   cout<<" ";
  60.               }
  61.  
  62.  
  63.              
  64.     j++;
  65.             }
  66.     i++;
  67.     limit1--;
  68.     limit2++;
  69.          }
  70.          system("pause");
  71.          return 0;
  72.  
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement