Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <cmath>
- #include <cstring>
- #include <stdio.h>
- #include <iomanip>
- #include <vector>
- #include <set>
- #include <map>
- #include <queue>
- #include <stack>
- #include <cstdlib>
- #include <cassert>
- #include <random>
- #include <time.h>
- #define fi first
- #define se second
- #define pb emplace_back
- #define all(x) x.begin(),x.end()
- #define re return
- #define mp make_pair
- #define sz(x) ((int)(x).size())
- using namespace std;
- typedef long long ll;
- const double pi = 3.14159265;
- const ll mod = 1e9 + 7;
- const ll N = 2e5 + 5;
- const ll P = 239;
- const ll INF = 2e18;
- int main()
- {
- freopen("proper.in ", "r", stdin);
- freopen("proper.out", "w", stdout);
- cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
- string s;
- string a;
- while(getline(cin, a))
- {
- s += a;
- s += ',';
- }
- bool start = true;
- int viv = 0;
- for (int i = 0; i < sz(s); i++)
- {
- if(s[i] == '.' || s[i] == '?' || s[i] == '!')
- {
- start = true;
- continue;
- }
- if(s[i] >= 'A' && s[i] <= 'Z')
- {
- if(start == true)
- {
- start = false;
- continue;
- }
- string q;
- q += s[i];
- i++;
- while(i < sz(s) && s[i] >= 'a' && s[i] <= 'z')
- {
- q += s[i];
- i++;
- }
- if(viv == 1){
- cout << ' ';
- viv = 0;
- }
- if(viv == 2){
- cout << '\n';
- viv = 0;
- }
- cout << q;
- while(i < sz(s) && (s[i] < 'a' || s[i] > 'z') && (s[i] < 'A' || s[i] > 'Z'))
- {
- if(s[i] == '.' || s[i] == '?' || s[i] == '!')
- {
- start = true;
- viv = 2;
- break;
- }
- i++;
- }
- if(start == true)
- continue;
- if(i == sz(s))
- break;
- if(s[i] >= 'a')
- {
- viv = 2;
- }
- else
- {
- viv = 1;
- i--;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement