Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- using namespace std;
- int main()
- {
- char s[201];
- int n;
- cin>>n;
- cin.ignore();
- cin.getline(s,200);
- char *p;
- p=strtok(s," ");
- int k=n;
- while(p)
- {
- int x=strlen(p);
- if(x>n)
- {
- cout<<"IMPOSIBIL";
- break;
- }
- if(k<x)
- {
- while(k)
- {
- cout<<"*";
- k--;
- }
- k=n-x-1;
- cout<<endl<<p<<" ";
- }
- else if(k==x)
- {
- cout<<p<<endl;
- k=n;
- }
- else
- {
- k=k-x-1;
- cout<<p<<" ";
- }
- p=strtok(NULL," ");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement