题解 | #简写单词#
简写单词
https://www.nowcoder.com/practice/0cfa856bf0d649b88f6260d878f35bb4
#include <stdio.h> #include<string.h> int main() { char str[5001] = { 0 }; //输入 gets(str); int len = strlen(str); //输出 for (int i = 0; i < len; i++) { if (i == 0 && str[i] >= 'a' && str[i] <= 'z') { printf("%c", str[i] - 32); } if (str[i] == ' ' && str[i + 1] >= 'a' && str[i + 1] <= 'z') { printf("%c", str[i + 1] - 32); } if (i == 0 && str[i] >= 'A' && str[i] <= 'Z') { printf("%c", str[i]); } if (str[i] == ' ' && str[i + 1] >= 'A' && str[i + 1] <= 'Z') { printf("%c", str[i + 1]); } } return 0; }