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-22 05:19:48
|
An easy one !
look at the "else", you'll see getPattern1 instead of getPattern2.
At 13.11 21/07/01 -0400, you wrote:
>To me, this code looks fine. When I execute the program it should give me a
>reverse of the first pattern when I choose pattern2, but it gives me the same
>output as pattern1.
>#include<iostream>
>
>
>using namespace std;
>
>//*****function prototypes
>void getPattern1(int &, int &);
>void getPattern2(int &, int &);
>
>
>int main()
>
>{
> int pattern = 0;
> int lines = 0;
> int stars = 0;
>
> cout << "Enter 1 for pattern1 or 2 for pattern2: " << endl;
> cin >> pattern;
>
> if (pattern == 1)
> {
>getPattern1(lines, stars);
> }
> else
> {
>getPattern1(lines, stars);
> }
>return 0;
>}
>
>
>//*****functions*****
>void getPattern1(int &lines, int &stars)
>{
> lines = 9;
> while (lines > 0)
> {
>stars = lines;
>while (stars > 0)
>{
>cout << '*';
>stars--;
>}
>cout << '\n';
>lines--;
> }
>}
>void getPattern2(int &lines, int &stars)
>{
>
> lines = 1;
> while (lines < 10)
> {
>stars = lines;
>while (stars < 10)
>{
>cout << '*';
>stars++;
>}
>cout << '\n';
>lines++;
> }
>
>}
>
--
gisan
gi...@li...
|