Attachment 48264
Can I print this in java using loops ? THANKS
![]() |
Attachment 48264
Can I print this in java using loops ? THANKS
Yes.
create a 2d array that contains a mapping for each character and it's position.
i.e. 1=b, 2=o, 0=' '.
[1 2 2 0 0]
[1 2 2 1 0]
Then loop through each line and each character and, using a switch statement, print out the character:
for(I=0 to lastLine){
for(j=0 to lastChar){
switch(map[i][j]){
case 1:print('b');
case 2:print('o');
case 0:print(' ');
default:
}
}
print ('\n');
}
The is the pusedo code, the rest is up to you.
All times are GMT -7. The time now is 11:58 PM. |