Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. // write your code here. justify.cpp is currently not doing anything
  2. string s = "";
  3.  
  4. int p = 0;
  5. int nLine= in.length() / width;
  6.  
  7. for (int x = 0; x <= nLine; x++)
  8. {
  9. if (x == nLine){
  10. for (int i = p; i < (p+in.length()%width); i++){
  11. s.append(in.substr(i, 1));
  12. }
  13. }
  14. if (x < nLine){
  15. for (int i = p; i < p + width; i++){
  16. s.append(in.substr(i, 1)); //s[i] = in[i]
  17.  
  18. if (s.at(width) == ' ') //Attempt at first condition, Remove space if the space start a line. NOT WORKING
  19. s.erase(width, 1);
  20. }
  21. }
  22.  
  23. p += width;
  24. out.push_back(s);
  25. s.assign("");
  26. }
  27.  
  28.  
  29. return ERROR_NONE;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement