[Dev-C++] RE: Can anyone figure this one out?(I did...)
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Julio L. <ju2...@ya...> - 2001-07-23 07:03:47
|
I fixed your problem with getPattern2:
#include <iostream.h>
#include <stdlib.h>
//*****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: ";
cin >> pattern;
cout << "\n";
if (pattern == 1)
{
getPattern1(lines, stars);
}
else
{
getPattern2(lines, stars);
}
system("PAUSE");
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 > 0)
{
cout << '*';
stars--;
}
cout << '\n';
lines++;
}
}
=====
Julio
__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/
|