Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- string s;
- while(getline(cin,s))
- {
- int len=s.size();
- string ans="";
- int i,j,k;
- for(i=0; i<len; i++)
- {
- if(s[i]==' ' && s[i+1]==' ')
- {
- j=i;
- k=0;
- while(s[j]==' ')
- {
- j++;
- k++;
- }
- k--;
- while(k--)
- ans+=' ';
- i=j-1;
- }
- else if(s[i]==' ' && s[i+1]==',')
- {
- ans+=',';
- i++;
- }
- else if(s[i]==' ' && s[i+1]=='.')
- {
- ans+='.';
- i++;
- }
- else
- ans+=s[i];
- }
- cout<<ans<<endl;
- s.clear();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement