Advertisement
ahamed210

Untitled

Aug 4th, 2021
818
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef int l;
  4. typedef long long ll;
  5. #define ft freopen("input.txt", "r", stdin)
  6. #define ftt freopen("output2.txt", "w", stdout)
  7. #define loop(a, b) for(int i = a; i < b; i++)
  8. #define max 100005
  9. #define PI acos(-1.0)
  10.  
  11. int main()
  12. {
  13.     //ft;
  14.     //ftt;
  15.     char s[max];
  16.     l c = 0;
  17.     while(scanf(" %[^\n]", &s) != EOF){
  18.         if(c != 0) cout << endl;
  19.         l p = strlen(s);
  20.         loop(0, p){
  21.             if(s[i] == 32 && s[i+1] == 32) cout << s[i+1];
  22.             else if((s[i]==32) && (s[i+1] == ',' || s[i+1] == '.')){
  23.                 cout << s[i+1];
  24.             }
  25.             else if(s[i] == 32 && s[i-1] == 32) continue;
  26.             else if((s[i] == ',' || s[i] == '.') && s[i-1] != 32) cout << s[i];
  27.             else {
  28.                 if ((s[i] != ',' && s[i] != '.')) cout << s[i];
  29.             }
  30.         }
  31.         //cout << endl;
  32.         c++;
  33.     }
  34.    
  35.     return 0;
  36. }
  37.  
  38. // abc def .
  39. // abc  def   .
  40. // abc  ,  def.
  41. // abc, def.
  42. // abc,   def, hi.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement