[Dev-C++] Can anyone figure this one out?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: <Tre...@ao...> - 2001-07-21 17:11:14
|
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++;
}
}
|