题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2026
参考代码一:
#include <stdio.h>
#include <string.h>
int main()
{
char s[101];
int i;
while(gets(s))
{
for(i=0;i<strlen(s);i++)
{
if(i==0)
s[i]=s[i]-'a'+'A';
else if(s[i]==' ')
s[i+1]=s[i+1]-'a'+'A';
}
puts(s);
}
return 0;
}
参考代码二:
#include <stdio.h>
#include <string.h>
int main()
{
char s[101];
int i;
while(gets(s))
{
s[0]-=32;
for(i=0;i<strlen(s);i++)
{
if(s[i]==' ')
s[i+1]-=32;;
}
puts(s);
}
return 0;
}