题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2026
//C++代码
#include<iostream>
#include<cstring>
#include<string>
#include<cctype>
using namespace std;
int main(){
char a[105];
while(cin.getline(a,105)){
int i,len=strlen(a);
a[0]=toupper(a[0]);
for(i=1;i<len;i++){
if(a[i-1]==' ') a[i]=toupper(a[i]);
}
cout<<a<<endl;
}
return 0;
}
本文提供了一个使用C++解决HDU 2026编程问题的示例代码,该问题要求读取一行字符串,并将每个单词的首字母转换为大写。通过使用getline获取输入并结合toupper进行字符转换,实现了字符串的恰当格式化。
3471

被折叠的 条评论
为什么被折叠?



