Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://www.facebook.com/CungHocLapTrinhUIT/
- #include <stdio.h>
- void strNormal(char *str)
- {
- int j = 0;
- for (int i = 0; str[i] != 0; i++)
- {
- if (str[i] != ' ')
- {
- if (str[i - 1] == ' ')
- {
- if (str[i] > 96 && str[i] < 123)
- str[j++] = str[i] - 32;
- else
- str[j++] = str[i];
- }
- else
- {
- if (str[i] > 64 && str[i] < 91)
- str[j++] = str[i] + 32;
- else
- str[j++] = str[i];
- }
- }
- else
- {
- if (i != 0 && str[i - 1] != ' ')
- {
- str[j++] = str[i];
- }
- }
- }
- str[0] = (str[0] > 96 ? str[0] - 32 : str[0]);
- str[j] = 0;
- }
- void main()
- {
- char str[1024];
- gets(str);
- strNormal(str);
- puts(str);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement