Re: [Dev-C++] Can anyone figure this one out?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Luigi S. <gi...@li...> - 2001-07-23 04:05:03
|
Sorry for my previous answer ... it was not complete.
Your getPattern2 function should have:
the first while loop that goes from 1 to 10 and the second that goes
from the value of lines to 0 (like the second loop of getPattern1)
try this code:
#include <iostream>
//*****function prototypes
void getPattern1();
void getPattern2();
int main()
{
int pattern; // will be read from cin, no need to initialize
cout << "Enter 1 for pattern1 or 2 for pattern2: " << endl;
cin >> pattern;
if (pattern == 1)
getPattern1();
else
getPattern2();
return 0;
}
//*****functions*****
void getPattern1()
{
int lines = 9;
while (lines > 0)
{
int stars = lines;
while (stars > 0)
{
cout << '*';
stars--;
}
cout << '\n';
lines--;
}
}
void getPattern2()
{
int lines = 1;
while (lines < 10)
{
int stars = lines;
while (stars > 0)
{
cout << '*';
stars--;
}
cout << '\n';
lines++;
}
}
At 08.56 22/07/01 -0400, you wrote:
>I did find that mistake, but after I recompiled and executed the program it
>still gave me the same pattern as before.....same problem....please help
--
gisan
gi...@li...
|