|
anybody can solve it for me...
Write a method that converts its String parameter so that letters are written in block of five characters long.
Example output...
Plain: My Name is Hazlina
Blocked:MyNam eisHa zlina
poning dah pikior.. pakai integer pun tak jadi sorting nye...
nikan pula string... |
|
|
|
|
|
|
|
Originally posted by azharfcsit at 13-9-2006 05:26 PM
anybody can solve it for me...
Write a method that converts its String parameter so that letters are written in block of five characters long.
Example output...
Plain: My Name is Hazlina
...
aku bagi algorithm je ye.
1) mula2 buang semua whitespace (spacebar, ' ', ataupun \n)
2) initialize empy master string
while ( current string length is greater than 5 characters) {
potong the first five characters from the current string,
buat new string, append pada satu master string
}
append remainder pada master string |
Rate
-
1
View Rating Log
-
|
|
|
|
|
|
|
I would do like this:
1. buang semua whitespace or \n
2. initialize empty master string
3. for (i = 1; i <= length of string, i++)
3.1 print character of string, referred to index i (guna substring)
3.2 if i mod 5 = 0 then print space
sekian terima kasih :bgrin: |
Rate
-
1
View Rating Log
-
|
|
|
|
|
|
|
Originally posted by shahnazz at 14-9-2006 09:01 AM
I would do like this:
1. buang semua whitespace or \n
2. initialize empty master string
3. for (i = 1; i <= length of string, i++)
3.1 print character of string, referred to index i (g ...
yes yang ni pun best gak... tq shahnazz quite elegant. instead of substring bole guna charAt je since dah browse by char. careful with indexing (array offset by 1). |
|
|
|
|
|
|
|
careful with indexing (array offset by 1).
of course... :bgrin: tu algorithm aje |
|
|
|
|
|
|
|
orite guys TQ..
i pun dah try wat nih...
very helpful algorithm... |
|
|
|
|
|
|
|
aku pulak baru nak belajar j2ee....sungguh complicated :geram:.byk sgt tools yg nak di mix dan match.itu belum lagi setting utk deploy kat appserver.
It's a XML jungle in j2ee...semoga aku dapat cari jalan pulang...:stp: |
|
|
|
|
|
|
|
Reply #7 ultra78's post
good experience tu, jangan sia-siakan peluang nak belajar J2EE in a real environment...
good luck :bgrin: |
|
|
|
|
|
|
|
Reply #8 shahnazz's post
masalahnya nak kena maintain code yg sedia ada dan bukan nak develop benda baru..ejb satu mimpi ngeri..:nyorok: |
|
|
|
|
|
|
| |
|