输入英文句子,将该句子中每一个单词的首字母改写成大写字母
人气:416 ℃ 时间:2020-04-09 20:13:26
解答
C++?比如说 若输入:I am a student to take the examination., 则应输出:I Am A Student To Take The Examination.。方法1限制单词长度:#include #include #include int main(){char c, *pstr;char szWord[16]; while(1){pstr = szWord;while((c = getchar()) != ' ' && c != '\n' && c != EOF){*pstr++ = c;}if(c == ' ')*pstr++ = ' '; *pstr = '\0';*szWord = toupper(*szWord); printf("%s", szWord);;memset(szWord, 0, 16); if(c == '\n' || c == EOF)break;}} 方法二限制句子长度:#include #include int main() {char szLine[64], *pstr = szLine;char c; gets(szLine); do{ if(isalpha(*pstr)) {*pstr = toupper(*pstr); } while(*pstr++ != ' ' && *pstr != '\0');}while(*pstr != '\0'); printf("%s", szLine); }建议、 遇到经典例子最好存起来 好好学C,是基础,很重要
推荐
猜你喜欢
- 镀锌钢管1/2"
- 1,2,3,4,5这5个数字算22,用且只能用加减乘除,只能用一次
- 从鲁肃对吕蒙的态度变化可以看出,鲁肃具有一个好领导必备的什么品质
- 24分之7×14分之6=
- 720除37乘36用简便方法怎么做
- 2根绳子,第一根比第二根长16米,第一根绳长是第二根的5倍,2根绳子分别长多少米
- is this museum ___ we visited last year
- this coming Sunday是什么时态?this Sunday又是什么时态?两者一样吗?