ACM2026

时间:2025-04-18 17:04:07
/*

首字母变大写

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<iostream>
#include<cstring>
int main()
{
using namespace std;
char a[],t;
int i,l;
while()
{
cin.getline(a,); t='';
l=strlen(a);
a[]=toupper(a[]);
for(i=;i<l;i++)
if(a[i-]==' ')
a[i]=toupper(a[i]);
puts(a); }
return ;
}
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
char ch[];
bool flag=;
char f;
while(gets(ch)){
int len=strlen(ch);
f=ch[]-;
cout<<f;
for(int i=;i<len;i++){
if(flag==){
f=ch[i]-;
cout<<f;
flag=;
}
else cout<<ch[i];
if(ch[i]==' ') flag=; }
cout<<endl;
}
}

相关文章