Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <stdio.h>
- #include <cstdlib>
- #include <ctype.h>
- using namespace std;
- int main()
- {
- char s[256];
- gets(s);
- int n = strlen(s);
- for (int i = 0; i < n - 1; i++)
- if (s[i] == ' ' && s[i + 1] == ' ')
- {
- strcpy(s + i, s + i + 1);
- i--;
- n--;
- }
- puts(s);
- ///2
- for (int i = 0; i < n; i++)
- if (s[i] == ' ')
- {
- s[i - 1] = toupper(s[i - 1]);
- s[i + 1] = toupper(s[i + 1]);
- }
- if (islower(s[0]))
- s[0] = toupper(s[0]);
- if (islower(s[n - 1]))
- s[n - 1] = toupper(s[n - 1]);
- puts(s);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement