Advertisement
Guest User

no.cpp

a guest
Jan 18th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int N, K, z = 0;
  7.  
  8. int main() {
  9. freopen("word.in", "r", stdin);
  10. freopen("word.out", "w", stdout);
  11. ios::sync_with_stdio(0);
  12. cin.tie(NULL);
  13. cin >> N >> K;
  14. N = N - 1;
  15. while(N) {
  16. string word; cin >> word;
  17. z += (int) word.size();
  18. if(z <= K) {
  19. cout << word << " ";
  20. continue;
  21. }
  22. z = (int) word.size();
  23. cout << "\n" << word << " ";
  24. }
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement