---GGGGGGGGGGGGGGGGGG
---------GGGGGGGGGGGG
---------------GGGGGG
---------------------
---------------BBBBBB
---------BBBBBBBBBBBB
---BBBBBBBBBBBBBBBBBB
(note they are supposed to be all in line with each other but it got messed up
when I posted this)
and this is my code
include <stdio.h>
include <conio.h>
main()
{
int i, j, Eritrea;
printf("Input the Size of the Flag: ");
scanf("%d",&Eritrea);
for (i = 0; i < Eritrea / 2; ++i) {
for (j = 0; j < i; ++j)
printf("-");
for (; j < Eritrea; ++j)
printf("G");
printf("\n");
}
for (j = 0; j < Eritrea; ++j)
printf("-");
printf("\n");
for (i = 0; i < Eritrea / 2; ++i) {
for (j = 0; j < Eritrea / 2 - i - 1; ++j)
printf("-");
for (;j<Eritrea; ++j)
printf("B");
printf("\n");
}
getch();
}
will anyone ghelp me out with this?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
#include<stdio.h>#include<conio.h>intmain(){inti,j,Eritrea;charch;printf("Input the Size of the Flag: ");scanf("%d",&Eritrea);for(i=0;i<Eritrea/2;++i){for(j=0;j<i;++j){printf("-");}for(;j<Eritrea;++j){printf("G");}printf("\n");}for(j=0;j<Eritrea;++j){printf("-");}printf("\n");for(i=0;i<Eritrea/2;++i){for(j=0;j<Eritrea/2-i-1;++j){printf("-");}for(;j<Eritrea;++j){printf("B");}printf("\n");}ch=getch();return0;}
the second for(;;) never gets executed, on the first loop, because i and j
both equal 0.
...what this means is that there is a flaw in your logic at this point.
The "-" never gets printed because i=0 and j=0,
while your statement says (to the effect):
"while j (is less than) i, do this..."
j is equal to i, therefore, the loop is skipped.
To correct the situation, you need to give i an initial value.
Steve
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Edit I already added an initial value but still the output is still different
what should I add? ; it still does not give me the ouput I this output when I
input 7
whoah I did not know that, I learned something new , at first I thought it was
a typo I made then it compiled whoah
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2011-03-12
do you want to upgrade quickly in maple story?why not Buy Maplestory
Mesos to enlarge your enquipment?our website
sellCheap Maplestory Mesos and provide all
kinds of service.get going!you will get more discount when you Buy Maplestory
Mesos from us.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I need to have this output:
---GGGGGGGGGGGGGGGGGG
---------GGGGGGGGGGGG
---------------GGGGGG
---------------------
---------------BBBBBB
---------BBBBBBBBBBBB
---BBBBBBBBBBBBBBBBBB
(note they are supposed to be all in line with each other but it got messed up
when I posted this)
and this is my code
include <stdio.h>
include <conio.h>
main()
{
int i, j, Eritrea;
printf("Input the Size of the Flag: ");
scanf("%d",&Eritrea);
for (i = 0; i < Eritrea / 2; ++i) {
for (j = 0; j < i; ++j)
printf("-");
for (; j < Eritrea; ++j)
printf("G");
printf("\n");
}
for (j = 0; j < Eritrea; ++j)
printf("-");
printf("\n");
for (i = 0; i < Eritrea / 2; ++i) {
for (j = 0; j < Eritrea / 2 - i - 1; ++j)
printf("-");
for (;j<Eritrea; ++j)
printf("B");
printf("\n");
}
getch();
}
will anyone ghelp me out with this?
I have made a few corrections to your code:
1) Here:
printf("Input the Size of the Flag: ");
what is the input parameter ?
2) Here:
for(i = 0; i < Eritrea / 2; ++i)
{
for(j = 0; j < i; ++j)
i equals 0
j equals 0
(...; while j < i;...)
the second for(;;) never gets executed, on the first loop, because i and j
both equal 0.
This forum is crap!!!
Code gets smushed so you can't read it.
Try it again!
include <stdio.h>
include <conio.h>
int main()
{
int i, j, Eritrea;
char ch;
printf("Input the Size of the Flag: ");
scanf("%d",&Eritrea);
for(i = 0; i < Eritrea / 2; ++i)
{
for(j = 0; j < i; ++j)
{
printf("-");
}
for(; j < Eritrea; ++j)
{
printf("G");
}
printf("\n");
}
for(j = 0; j < Eritrea; ++j)
{
printf("-");
}
printf("\n");
for(i = 0; i < Eritrea / 2; ++i)
{
for(j = 0; j < Eritrea / 2 - i - 1; ++j)
{
printf("-");
}
for (;j<Eritrea; ++j)
{
printf("B");
}
printf("\n");
}
ch = getch();
return 0;
}
uhmm excuse me but there is supposed to be and "-" before the "G" how do I fix
that?
3 is the input parameter
Yes, I explained that in #2:
2) Here:
for(i = 0; i < Eritrea / 2; ++i)
{
for(j = 0; j < i; ++j)
i equals 0
j equals 0
(...; while j < i;...)
the second for(;;) never gets executed, on the first loop, because i and j
both equal 0.
...what this means is that there is a flaw in your logic at this point.
The "-" never gets printed because i=0 and j=0,
while your statement says (to the effect):
"while j (is less than) i, do this..."
j is equal to i, therefore, the loop is skipped.
To correct the situation, you need to give i an initial value.
Steve
but wait it is supposed to be 3 " - " can you suggest an intiial value or any
will do?
Edit I already added an initial value but still the output is still different
what should I add? ; it still does not give me the ouput I this output when I
input 7
---GGGGGGGGGGGGGGGGGG
---------GGGGGGGGGGGG
---------------GGGGGG
---------------------
---------------BBBBBB
---------BBBBBBBBBBBB
---BBBBBBBBBBBBBBBBBB
The following code seems to work (as long as you use odd input values
only):
include <stdio.h>
include <conio.h>
int main()
{
int i, j, Eritrea;
int x, y, z;
char ch;
printf("Input the Size of the Flag: ");
scanf("%d",&Eritrea);
y = Eritrea * 3;
x = y - 3;
for(i = 0; i < Eritrea / 2; i++)
{
z = y - x;
for(j = 0; j < z; j++)
{
printf("-");
}
for(; j < y; j++)
{
printf("G");
}
printf("\n");
x -= 6;
}
for(j = 0; j < y; j++)
{
printf("-");
}
printf("\n");
x = 6;
for(i = 0; i < Eritrea / 2; i++)
{
z = y - x;
for(j = 0; j < z; j++)
{
printf("-");
}
for(; j < y; j++)
{
printf("B");
}
printf("\n");
x += 6;
}
ch = getch();
return 0;
}
I'm certain there is a better way of doing this.
Steve
for(; j < y; j++)
that one is that supposed to be an error/ there is no j=1? or it is okay like
that/
Yes, that is correct.
At that point in the code, we want j to procede with it's present value
and continue counting upwards from there.
Steve
whoah I did not know that, I learned something new , at first I thought it was
a typo I made then it compiled whoah
do you want to upgrade quickly in maple story?why not Buy Maplestory
Mesos to enlarge your enquipment?our website
sellCheap Maplestory Mesos and provide all
kinds of service.get going!you will get more discount when you Buy Maplestory
Mesos from us.