首字母大写
2017-09-15 12:59
162 查看
题目描述
对一个字符串中的所有单词,如果单词的首字母不是大写字母,则把单词的首字母变成大写字母。在字符串中,单词之间通过空白符分隔,空白符包括:空格(' ')、制表符('\t')、回车符('\r')、换行符('\n')。
输入
输入一行:待处理的字符串(长度小于100)。
输出
可能有多组测试数据,对于每组数据,输出一行:转换后的字符串。
样例输入
if so, you already have a google account. you can sign in on the right.
样例输出
If So, You Already Have A Google Account. You Can Sign In On The Right.
提示
#include <iostream>
#include <sstream>
#include <vector>
#include <cctype>
using namespace std;
int main(){
string s,buf;
while(getline(cin,s)){
vector<string> msg;
stringstream ss(s);
while(ss>>buf){buf[0]=toupper(buf[0]);msg.push_back(buf);}
int n=msg.size();
for(int i=0;i<n;i++)
if(i<n-1) cout<<msg[i]<<" ";else cout<<msg[i]<<"\n";
}
return 0;
}
相关文章推荐
- 首字母变大写
- 函数单词首字母大写并返回字符串
- textField去掉默认首字母大写
- 给定字符串,将单词首字母改成大写
- OS X 自带输入法关闭首字母大写、拼写纠正、双空格变点号
- 在bean中为属性命名时第二个字母不能大写
- Java入门小程序,使用Java转换用户输入字母为大写如何避开中文?
- Hdu 2026 首字母变大写
- 浅析Python中将单词首字母大写的capitalize()方法
- Java和Js中首字母大写的方法
- 将一段英语的每个单词首字母大写
- 首字母大写
- python 实现table name 首字母大写 (驼峰)
- D25 OC学习线路 C语言单词首字母大写并统计单词个数
- 使用jQuery 把一个JSP文件中的所有id名字替换成以b开头,再加上原来的名字(首字母变为大写)
- python开发_大小写转换,首字母大写,去除特殊字符
- 传入一个字符串,已知字符串只由字母组成,将其中的大写字母转换为小写,小写转换为大写,返回转换后的字符串
- 【暑期基础2】A HDU 2026 首字母变大写
- JAVA--第七周实验--输出24个希腊字母与26个大写英文字母--运用类的继承
- Java字符串首字母大写-高效方法