题解 | #首字母大写#
首字母大写
https://www.nowcoder.com/practice/91f9c70e7b6f4c0ab23744055632467a
#include <stdio.h> int Length(char a[]) { int n = 0; for (int i = 0; a[i] != '\0'; i++) { n++; } return n; } int main() { char a[100]; while (gets(a)) { int len = Length(a); for (int i = 0; i < len; i++) { if (i == 0 && a[i] >= 97 && a[i] <= 122) { a[i] -= 32; } else if (i != 0 && (a[i] == ' ' || a[i] == '\t' || a[i] == '\r' || a[i] == '\n')) { if (a[i + 1] >= 97 && a[i + 1] <= 122) { a[i + 1] -= 32; } } } puts(a); } return 0; }