a53

lungimerandmax

a53
Nov 11th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. ifstream fin("lungimerandmax.in");
  5. ofstream fout("lungimerandmax.out");
  6.  
  7. unsigned int l, m;
  8. char sir[10005], *p;
  9.  
  10. int main()
  11. {
  12. fin>>l;
  13. fin.get();
  14. fin.getline(sir, 10005);
  15. p=strtok(sir, " ");
  16. while(p)
  17. {
  18. if(strlen(p)+ m >l)
  19. fout<<'\n', m = 0;
  20. fout<<p<<" ";
  21. m+=strlen(p)+1;
  22. p=strtok(NULL, " ");
  23. }
  24. return 0;
  25. }
Add Comment
Please, Sign In to add comment