Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <cmath>
  4. #include <cstring>
  5. #include <stdio.h>
  6. #include <iomanip>
  7. #include <vector>
  8. #include <set>
  9. #include <map>
  10. #include <queue>
  11. #include <stack>
  12. #include <cstdlib>
  13. #include <cassert>
  14. #include <random>
  15. #include <time.h>
  16.  
  17. #define fi first
  18. #define se second
  19. #define pb emplace_back
  20. #define all(x) x.begin(),x.end()
  21. #define re return
  22. #define mp make_pair
  23. #define sz(x) ((int)(x).size())
  24.  
  25. using namespace std;
  26.  
  27. typedef long long ll;
  28.  
  29. const double pi = 3.14159265;
  30. const ll mod = 1e9 + 7;
  31. const ll N = 2e5 + 5;
  32. const ll P = 239;
  33. const ll INF = 2e18;
  34.  
  35.  
  36. int main()
  37. {
  38. freopen("proper.in ", "r", stdin);
  39. freopen("proper.out", "w", stdout);
  40. cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
  41. string s;
  42. string a;
  43. while(getline(cin, a))
  44. {
  45. s += a;
  46. s += ',';
  47. }
  48. bool start = true;
  49. int viv = 0;
  50. for (int i = 0; i < sz(s); i++)
  51. {
  52. if(s[i] == '.' || s[i] == '?' || s[i] == '!')
  53. {
  54. start = true;
  55. continue;
  56. }
  57. if(s[i] >= 'A' && s[i] <= 'Z')
  58. {
  59. if(start == true)
  60. {
  61. start = false;
  62. continue;
  63. }
  64. string q;
  65. q += s[i];
  66. i++;
  67. while(i < sz(s) && s[i] >= 'a' && s[i] <= 'z')
  68. {
  69. q += s[i];
  70. i++;
  71. }
  72. if(viv == 1){
  73. cout << ' ';
  74. viv = 0;
  75. }
  76. if(viv == 2){
  77. cout << '\n';
  78. viv = 0;
  79. }
  80. cout << q;
  81. while(i < sz(s) && (s[i] < 'a' || s[i] > 'z') && (s[i] < 'A' || s[i] > 'Z'))
  82. {
  83. if(s[i] == '.' || s[i] == '?' || s[i] == '!')
  84. {
  85. start = true;
  86. viv = 2;
  87. break;
  88. }
  89. i++;
  90. }
  91. if(start == true)
  92. continue;
  93. if(i == sz(s))
  94. break;
  95. if(s[i] >= 'a')
  96. {
  97. viv = 2;
  98. }
  99. else
  100. {
  101. viv = 1;
  102. i--;
  103. }
  104. }
  105. }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement