Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int N, K, z = 0;
- int main() {
- freopen("word.in", "r", stdin);
- freopen("word.out", "w", stdout);
- ios::sync_with_stdio(0);
- cin.tie(NULL);
- cin >> N >> K;
- N = N - 1;
- while(N) {
- string word; cin >> word;
- z += (int) word.size();
- if(z <= K) {
- cout << word << " ";
- continue;
- }
- z = (int) word.size();
- cout << "\n" << word << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement