You are viewing a single comment's thread. Return to all comments →
std::string sentence; getline(cin, sentence); int length = sentence.length(), columns = ceil(sqrt(length)), rows = floor(sqrt(length)); if(rows*columns < length) rows = columns; for(int i = 0; i < columns; ++i) { for(int j = 0; j < rows; ++j) { if(i + j * columns < length) cout << sentence[i + j * columns]; } cout << ' '; }
Seems like cookies are disabled on this browser, please enable them to open this website
Encryption
You are viewing a single comment's thread. Return to all comments →