|
From: Ioannis V. <no...@ya...> - 2001-07-20 17:59:04
|
putchar() is defined in <cstdio> but don't use putchar, use cout<<'*'; There are some logical errors but i thik you can vfind them. =20 =20 Ioannis =20 * Ioannis Vranos * Programming pages: http://www.noicys.f2s.com <http://www.noicys.f2s.com/>=20 * Alternative URL: http://run.to/noicys -----Original Message----- From: dev...@li... [mailto:dev...@li...] On Behalf Of Tre...@ao... Sent: Friday, July 20, 2001 7:46 PM To: dev...@li... Subject: Re: [Dev-C++] nested loop Thank you for your help :) I am now trying to reverse the pattern and I am=20 getting an infinite loop.....can you see what is wrong.....it looks fine to=20 me.=20 #include<iostream>=20 #include<string>=20 using namespace std;=20 int main()=20 {=20 int pattern =3D 0;=20 int lines =3D 0;=20 int stars;=20 cout << "Enter 1 for pattern1 or 2 for pattern2: " << endl;=20 cin >> pattern;=20 if (pattern =3D=3D 1)=20 {=20 lines =3D 9;=20 while (lines > 0)=20 {=20 stars =3D lines;=20 while (stars > 0)=20 {=20 putchar('*');=20 stars--;=20 }=20 putchar('\n');=20 lines--;=20 }=20 =20 }=20 else if (pattern =3D=3D 2)=20 {=20 lines =3D 9;=20 stars =3D 1;=20 while (lines > 0)=20 {=20 putchar('*');=20 stars++;=20 =20 while (stars < 10)=20 {=20 putchar('\n');=20 lines--;=20 }=20 =20 }=20 =20 } //end if=20 return 0;=20 }=20 |