Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // again.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- int _tmain(int argc, _TCHAR* argv[])
- {
- int i=0, j=0, totallength=0, totalwidth=0, northsouthtriangleheight=0, northsouthtrianglebase=0,
- eastwesttriangleheight=0, eastwesttrianglebase=0, squarecenter=5, limit1=0, limit2=0; //declaration
- cout<<"enter totallength of flower"; //user inputs the total length
- cin>>totallength; //variable stores it
- cout<<"enter totalwidth of flower";
- cin>>totalwidth;
- northsouthtriangleheight=(totallength-squarecenter)/2; // computing triangleheight and trianglebase
- northsouthtrianglebase=((northsouthtriangleheight*2)-1);
- eastwesttriangleheight=((totalwidth-squarecenter)/2);
- eastwesttrianglebase=((eastwesttriangleheight*2)-1);
- limit1=(eastwesttriangleheight+(northsouthtrianglebase/2)+1);
- limit2=(eastwesttriangleheight+(northsouthtrianglebase/2)+1);
- if(northsouthtriangleheight%2==0)
- {
- i=0, j=1;
- }
- else if(northsouthtriangleheight%2==1)
- {
- i=1, j=1;
- }
- while(i<=northsouthtriangleheight)
- {
- j=1;
- while(j<=totalwidth)
- {
- if(j<=eastwesttriangleheight)
- {
- cout<<" ";
- }
- else if(j>eastwesttriangleheight&&j<limit1)
- {
- cout<<" ";
- }
- else if((j>=limit1)&&(j<=limit2))
- {
- cout<<"*";
- }
- else if(j>limit2&&j<=totalwidth)
- {
- cout<<" ";
- }
- j++;
- }
- i++;
- limit1--;
- limit2++;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement