|
From: <Tre...@ao...> - 2001-07-20 17:46:17
|
Thank you for your help :) I am now trying to reverse the pattern and I am
getting an infinite loop.....can you see what is wrong.....it looks fine to
me.
#include<iostream>
#include<string>
using namespace std;
int main()
{
int pattern = 0;
int lines = 0;
int stars;
cout << "Enter 1 for pattern1 or 2 for pattern2: " << endl;
cin >> pattern;
if (pattern == 1)
{
lines = 9;
while (lines > 0)
{
stars = lines;
while (stars > 0)
{
putchar('*');
stars--;
}
putchar('\n');
lines--;
}
}
else if (pattern == 2)
{
lines = 9;
stars = 1;
while (lines > 0)
{
putchar('*');
stars++;
while (stars < 10)
{
putchar('\n');
lines--;
}
}
} //end if
return 0;
}
|