Thread: [Dev-C++] RE: RE: 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 19:37:32
|
That is not my code, I just fixed the problem they had
with getPattern2() function. I agree with you though,
I would not have passed lines or stars by reference,
and I would have used for loops not while loops...
FROM: yahoo.comDATE: 07/23/2001 04:00:30SUBJECT: RE:
[Dev-C++] RE: Can anyone figure this one out?(I
did...) 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 <<EMAIL: PROTECTED>> 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
> <EMAIL: PROTECTED>
>
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
_______________________________________________
Dev-cpp-users mailing list
<EMAIL: PROTECTED>
http://lists.sourceforge.net/lists/listinfo/dev-cpp-users
=====
Julio
__________________________________________________
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/
|
|
From: <jos...@ya...> - 2001-07-24 07:02:56
|
I know Julio. Please accept my apologies. I deleted the previous
message so I don't know who asked for help.
I forgot to mention that the reply was for that person and not for you.
Un saludo.
Chemanuel
--- Julio Lajara <ju2...@ya...> escribió: > That is not my
code, I just fixed the problem they had
> with getPattern2() function. I agree with you though,
> I would not have passed lines or stars by reference,
> and I would have used for loops not while loops...
>
> FROM: yahoo.comDATE: 07/23/2001 04:00:30SUBJECT: RE:
> [Dev-C++] RE: Can anyone figure this one out?(I
> did...) 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 <<EMAIL: PROTECTED>> 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
> > <EMAIL: PROTECTED>
> >
> 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
>
> _______________________________________________
> Dev-cpp-users mailing list
> <EMAIL: PROTECTED>
> http://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
>
> =====
> 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
|