Advertisement
STANAANDREY

2/12/2019

Dec 2nd, 2019
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. #include <stdio.h>
  4. #include <cstdlib>
  5. #include <ctype.h>
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     char s[256];
  11.     gets(s);
  12.     int n = strlen(s);
  13.     for (int i = 0; i < n - 1; i++)
  14.         if (s[i] == ' ' && s[i + 1] == ' ')
  15.         {
  16.             strcpy(s + i, s + i + 1);
  17.             i--;
  18.             n--;
  19.         }
  20.     puts(s);
  21.     ///2
  22.     for (int i = 0; i < n; i++)
  23.         if (s[i] == ' ')
  24.         {
  25.             s[i - 1] = toupper(s[i - 1]);
  26.             s[i + 1] = toupper(s[i + 1]);
  27.         }
  28.  
  29.     if (islower(s[0]))
  30.         s[0] = toupper(s[0]);
  31.     if (islower(s[n - 1]))
  32.         s[n - 1] = toupper(s[n - 1]);
  33.  
  34.     puts(s);
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement