#include<stdio.h> int main() { char a[100]; int i, j=1; printf("请输入一串字符:"); gets_s(a); for (i = 0; a[i] != ‘\0‘; i++)/*找出单词个数*/ { if (a[i] == ‘ ‘) j += 1; } printf("单词个数:%d\n", j); if (a[0] >= ‘a‘ && a[0] <= ‘z‘)/*判断首字母大小写并转换*/ a[0] -= 32; for (i = 0; a[i] != 0; i++) { printf("%c", a[i]); } }
原文地址:https://www.cnblogs.com/HGNET/p/11979897.html
时间: 2024-10-10 02:00:36