Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // write your code here. justify.cpp is currently not doing anything
- string s = "";
- int p = 0;
- int nLine= in.length() / width;
- for (int x = 0; x <= nLine; x++)
- {
- if (x == nLine){
- for (int i = p; i < (p+in.length()%width); i++){
- s.append(in.substr(i, 1));
- }
- }
- if (x < nLine){
- for (int i = p; i < p + width; i++){
- s.append(in.substr(i, 1)); //s[i] = in[i]
- if (s.at(width) == ' ') //Attempt at first condition, Remove space if the space start a line. NOT WORKING
- s.erase(width, 1);
- }
- }
- p += width;
- out.push_back(s);
- s.assign("");
- }
- return ERROR_NONE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement