一个c语言的问题:首字母变大写输入一个英文句子,将每个单词的第一个字母改成大写字母.如 input:i like it output:I Like It我的代码#includevoid main(){\x09char str[100],*p;\x09while(scanf("%s",str)!=EOF)\x09{\x09p=s

来源:学生作业帮助网 编辑:作业帮 时间:2024/08/30 01:00:41
一个c语言的问题:首字母变大写输入一个英文句子,将每个单词的第一个字母改成大写字母.如 input:i like it output:I Like It我的代码#includevoid main(){\x09char str[100],*p;\x09while(scanf(
xS[KA}1jTA? {0[kaw .BE;YoEЯq_35<0;gw>̙V绤])۷z~~#RczyC7O=q%uEKW㧏V䠴x`WF^bv@D:Βh^L0 #VaѪ^V{Lgg KJ|98K$d(+89$3SROwG6/Ī6?>g\vvK8/ljr^UdžU TƐ8 +أzAo|5](%9^蕻n"E¾Sw6r.Dt![up4߂+L' tMg5bJ+-M8WN2Y5ù}~#`p &b|>~ UT@3'&NQwA 5

一个c语言的问题:首字母变大写输入一个英文句子,将每个单词的第一个字母改成大写字母.如 input:i like it output:I Like It我的代码#includevoid main(){\x09char str[100],*p;\x09while(scanf("%s",str)!=EOF)\x09{\x09p=s
一个c语言的问题:首字母变大写
输入一个英文句子,将每个单词的第一个字母改成大写字母.如
input:i like it
output:I Like It
我的代码
#include
void main()
{\x09char str[100],*p;
\x09while(scanf("%s",str)!=EOF)
\x09{\x09p=str;
\x09\x09*p=*p-32;
\x09\x09for(p=str+1;*p!='\0';p++)
\x09\x09{\x09
\x09\x09\x09if(*p=' ')\x09
\x09\x09\x09{\x09*(p+1)=*(p+1)-32;
\x09\x09\x09}
\x09\x09}
printf("%s\n",str);
\x09}
}

一个c语言的问题:首字母变大写输入一个英文句子,将每个单词的第一个字母改成大写字母.如 input:i like it output:I Like It我的代码#includevoid main(){\x09char str[100],*p;\x09while(scanf("%s",str)!=EOF)\x09{\x09p=s
#include
#include
void main()
{
char str[100],*p;
while(gets(str)!=EOF)
{p=str;
*p=toupper(*p);
for(p=str+1;*p!='\0';p++)
{
if(*(p-1)==' ')
{
*p=toupper(*p);
}
}
printf("%s\n",str);
}
}