Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- /* PROBLEMA DE LA EXAMEN NU MI SE PARE FOARTE GREU DE REZOLVAT IN TIMPUL ACORDAT */
- int main()
- {
- string s, a;
- int i, L, k=0;
- cin>>L;
- getline(cin, s);
- s=s+' ';
- int j=0;
- for (i=0; i<s.size(); i++)
- {
- if (s[i]!=' ')
- {
- a[j]=s[i];
- j++;
- }
- else
- {
- k=k+a.size();
- if (k<=L)
- {
- cout <<a<<' ';
- k++;
- a=' ';
- j=0;
- }
- else
- {
- cout<<endl;
- cout<<a;
- k=a.size()+1;
- a=' ';
- j=0;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement