#include%26lt;string%26gt;
#include%26lt;iostream%26gt;
#include%26lt;cmath%26gt;
using namespace std;
int main ()
{
int a, b=1, c, d, e;
while ( b %26gt; 0 )
{
cout %26lt;%26lt; endl;
cout %26lt;%26lt; "Enter a number from 3 to 15 and I will draw you an hourglass. ";
cin %26gt;%26gt; a;
while ( a %26lt; 3 || a %26gt; 15 )
{
while ( a %26lt; 3 %26amp;%26amp; a != 0)
{
cout %26lt;%26lt; endl;
cout %26lt;%26lt; "The number of rows is not enough for me to make an hourglass. " %26lt;%26lt; endl;
cout %26lt;%26lt; "Enter again : ";
cin %26gt;%26gt; a;
}
while ( a %26gt; 15 )
{
cout %26lt;%26lt; endl;
cout %26lt;%26lt; "That is too many rows for me to make an hourglass." %26lt;%26lt;
endl;
cout %26lt;%26lt; "Enter again : ";
cin %26gt;%26gt; a;
}
while ( a == 0 )
{
cout %26lt;%26lt; "Good Bye"%26lt;%26lt; endl;
return 0;}
}
if ( a%2 == 0)
a = a + 1;
for ( c = a/2 + 1; c %26gt;= 1; c--)
{
for ( e = c; e %26lt;= c; e++)
cout %26lt;%26lt; "*";
for ( d = 2*c-1; d %26gt; 0; d--)
{
cout %26lt;%26lt; "*";
}
cout %26lt;%26lt; endl;
}
}
return 0;
}
supposed to look liek this %26gt;%26gt;%26gt; when i enter 3 then is that with the middle star to be in the middle
***
*
***
Making an hourglass program in c++??
#include %26lt;windows.h%26gt;
// set mouse cursor to wait
HCURSOR hOldCursor = SetCursor(LoadCursor(NULL, IDC_WAIT));
// do your processing that takes some time...
// restore old cursor
SetCursor(hOldCursor);
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment