1121. Capitalize first letter

Source: Internet
Author: User
Tags uppercase letter

Title Description:

For all words in a string, if the first letter of the word is not an uppercase letter, the first letter of the word becomes uppercase.
In the string, the words are separated by a white space character, including a space ('), a tab (' \ t '), a carriage return (' \ R '), and a newline character (' \ n ').

Input:

Enter a line: the string to be processed (less than 100 in length).

Output:

There may be multiple sets of test data, for each set of data,
Output one line: the converted string.

Sample input:
If so, you already has a Google account. You can sign in to the right.
Sample output:
If So, you already has A Google account. You Can sign in to the right.
Source:
2008 the computer research of the graphics Laboratory of Peking University The real problem

#include <iostream>#include<cstring>using namespacestd;intMain () {strings;  while(Getline (cin,s)) {if(s[0]<='Z'&& s[0]>='a') s[0]=s[0]- +;  for(intI=1; I<s.size (); i++){            if(s[i]==' '|| s[i]=='\ t'|| s[i]=='\ r'|| s[i]=='\ n'){                    if(s[i+1]<='Z'&& s[1+i]>='a') s[1+i]=s[i+1]- +; }} cout<<s<<Endl; }    return 0;} 

1121. Capitalize first letter

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.