Untitled
unknown
plain_text
4 years ago
668 B
4
Indexable
using System; namespace Nothing{ class Program { string WrapThis(string s, int len){ string ret = ""; string curWord = ""; int n = s.Length; int curLineLength = 0; for(int i = 0; i < n; i++){ if(curLineLength == len) ret += "\n", curLineLength = 0; if(s[i] == new string(" ")){ if(curWord != new string("") ret += curWord, curWord = ""; } else curWord += s[i]; } if(curWord != new string("") ret += curWord; return ret; } public static void Main(){ string input = "asfk ssdfub a ufbuasfhu hasufhu uabf a c dd e g e a f e g "; int lineLenth = 10; Console.WriteLine(WrapThis(input, lineLength)); } }
Editor is loading...