时间限制: 1 Sec 内存限制: 64 MB
提交: 219 解决: 92
[提交][状态][讨论版]
题目描述
输入一个英文句子,将每个单词的第一个字母改成大写字母。
输入
输入数据包含多个测试实例,每个测试实例是一个长度不超过100的英文句子,占一行。
输出
请输出按照要求改写后的英文句子。
样例输入
i like acm i want to get an accepted
样例输出
I Like Acm I Want To Get An Accepted
#include
#include
using namespace std;
void ma(char str[100])
{
int i,n;
char c;
for(i=0;;i++)
if(i==0)
str[0]=str[0]-32;
else if(str[i]=='\0')
break;
else if(str[i]==' ')
str[i+1]=str[i+1]-32;
for(n=0;n
{c=str[n];
cout<<c;
}
cout<<endl;
}
int main()
{
char str[100];
while(gets(str))
if(str[0]<'a'&&str[0]>'Z'||str[0]<'A'||str[0]>'z')
break;
else
ma(str);
return 0;
}