+ 1

How can I show this?

********* *0*0*0*0* ********* *0*0*0*0* *********

31st Oct 2017, 6:35 PM
zahra
zahra - avatar
5 Answers
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; }
31st Oct 2017, 8:14 PM
Zeke Williams
Zeke Williams - avatar
+ 2
cout the lines as written. If you want something else, program your best guess and ask for help.
31st Oct 2017, 6:46 PM
John Wells
John Wells - avatar
+ 1
where you're are getting trouble please let us know in brief.
31st Oct 2017, 6:44 PM
Vipul Walia
Vipul Walia - avatar
+ 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.
31st Oct 2017, 8:37 PM
Zeke Williams
Zeke Williams - avatar
0
@Zeke first if only needs to be: if (i%2 == 0) And giving the answer doesn't help them become a programmer.
31st Oct 2017, 8:24 PM
John Wells
John Wells - avatar