Just a comment.
If "lines" is assigned to 9 and 1 in getPattern1 and getPattern2,
respectively, why do you pass it as a pointer in the function? This
doesn't make any sense. You pass a paramter when you're going to use
it.
The same counts for "stars". You only assign the value of "lines" to
it.
My advice is to remove those parameters from the function call since
you don't need them and define "starts" and "lines" within the
functions getPattern1 and getPattern2.
hth
Chemanuel
--- Julio Lajara <ju2...@ya...> escribió: > 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/
>
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> http://lists.sourceforge.net/lists/listinfo/dev-cpp-users
_______________________________________________________________
Do You Yahoo!?
Yahoo! Messenger: Comunicación instantánea gratis con tu gente -
http://messenger.yahoo.es
|