+ 1
How can I show this?
********* *0*0*0*0* ********* *0*0*0*0* *********
5 Antworten
0
for (int i = 0; i < 5; ++i) {
for (int j = 0; j < 9; ++j) {
if (i == 0 || i % 2 == 0) {
cout << "*";
} else {
if ( j & 1 ) {
cout << "0";
} else {
cout << "*";
}
}
}
cout << endl;
}
+ 2
cout the lines as written. If you want something else, program your best guess and ask for help.
+ 1
where you're are getting trouble please let us know in brief.
+ 1
@John Yep, you're right, I did it in one minute and forgot to remove that part.
I would beg to differ on your second point however. I am against doing someone's homework, but I learned more than any other way by getting the answer and examining it until I understood it. When you have very little information to start with, examining code you don't understand yet can help open your mind tremendously. Sure, it might not make you better, but that's why there's practice, and it helps to know what to practice.
0
@Zeke first if only needs to be:
if (i%2 == 0)
And giving the answer doesn't help them become a programmer.