杭电acm2026 Problem Description输入一个英文句子,将每个单词的第一个字母改成大写字母.Input输入数据包含多个测试实例,每个测试实例是一个长度不超过100的英文句子,占一行.Output请输出按照要求

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/29 07:31:52
杭电acm2026 Problem Description输入一个英文句子,将每个单词的第一个字母改成大写字母.Input输入数据包含多个测试实例,每个测试实例是一个长度不超过100的英文句子,占一行.Output请输出按照要求

杭电acm2026 Problem Description输入一个英文句子,将每个单词的第一个字母改成大写字母.Input输入数据包含多个测试实例,每个测试实例是一个长度不超过100的英文句子,占一行.Output请输出按照要求
杭电acm2026
Problem Description
输入一个英文句子,将每个单词的第一个字母改成大写字母.
Input
输入数据包含多个测试实例,每个测试实例是一个长度不超过100的英文句子,占一行.
Output
请输出按照要求改写后的英文句子.
Sample Input
i like acm
i want to get an accepted
Sample Output
I Like Acm
I Want To Get An Accepted
我的代码:
#include
int main(void)
{
char str[100],*p;
while(gets(str)!=NULL)
{
p=str;
*p=*p-32;
while(*p++!=NULL)
{
\x05 if(*(p-1)==' ')
\x05\x05 *p=*p-32;
}
while(*p!=NULL)
printf("%c",*p++);
printf("\n");
p=0;
}
return 0;
}
出错原因:输出的是乱码
修改最后输出语句后
代码变为
#include
int main(void)
{
char str[100],*p;
while(gets(str)!=NULL)
{
p=str;
*p=*p-32;
while(*p++!=NULL)
{
\x05 if(*(p-1)==' ')
\x05\x05 *p=*p-32;
}
printf(“%s\n”,str);
p=0;
}
return 0;
}
这样就正确了
我想知道我第一个代码哪里出错 为什么出现乱码.

杭电acm2026 Problem Description输入一个英文句子,将每个单词的第一个字母改成大写字母.Input输入数据包含多个测试实例,每个测试实例是一个长度不超过100的英文句子,占一行.Output请输出按照要求
因为while(*p++!=NULL)当*p=NULL时,循环结束然后p=p+1;
接着运行while(*p!=NULL) *p已经不再str数组中他的值是不定的
所以会乱码

杭电acm2026 Problem Description输入一个英文句子,将每个单词的第一个字母改成大写字母.Input输入数据包含多个测试实例,每个测试实例是一个长度不超过100的英文句子,占一行.Output请输出按照要求 杭电ACM problem 1002 A + B Problem II为什么会WRONG ANSWER?计算结果没错啊?#include Pas de problem与Pas problem有何区别? problem 杭电acm1002解题思路.用C++Problem DescriptionI have a very simple problem for you.Given two integers A and B,your job is to calculate the Sum of A + B.InputThe first line of the input contains an integer T(1 杭电acm 1002 用c或者c++Problem DescriptionI have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B. InputThe first line of the input contains an integer T(1 杭电2504题为什么WA?又见GCDTime Limit:1000/1000 MS (Java/Others) Memory Limit:32768/32768 K (Java/Others)Total Submission(s):4020 Accepted Submission(s):1632Problem Description有三个正整数a,b,c(0 杭电ACM 2012 不能AC,哪里不对?Problem Description对于表达式n^2+n+41,当n在(x,y)范围内取整数值时(包括x,y)(-39 杭电acm 2035 题的算法是怎样的,杭电acm 2035 题的算法是怎样的,我要算法分析,不要代码!Problem Description求A^B的最后三位数表示的整数.说明:A^B的含义是“A的B次方”Input输入数据包含多个测试实 de de de 杭电 2010 杭电1051是什么意思 杭电G++是什么意思 杭电的 1100 杭电1014 No problem