Click here to Skip to main content
15,867,968 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have to write a program in java for wordwrap with minimum regard...
for example if we have "aaa bb cc ddddd" and want to wrap it in lines with this method the final form should be like this :
------ Line width: 6
aaa Remaining space: 3 (cost = 3 squared = 9)
bb cc Remaining space: 1 (cost = 1 squared = 1)
ddddd Remaining space: 1 (cost = 1 squared = 1)
attention that we don't know number of lines...I don't understand the algorithm which is in wikipedia ,in this link :
http://en.wikipedia.org/wiki/Word_wrap[^]
but unfortunately I still have problem with understanding the algorithm...can some one explain it with example for me ?
Posted
Comments
Sergey Alexandrovich Kryukov 26-Jan-12 20:54pm    
I wonder why? Just the exercise in programming? If so, you really need to prepare yourself to be able to solve the problems to the very end, develop a strong character; and with someone help you just waste time and loose the chance to develop this skill, which is critically important.
--SA
TorstenH. 27-Jan-12 2:01am    
Homework?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900