C + + Brush title--1938: Capitalize the first letter

Source: Internet
Author: User

Description
Enter an English sentence and change the first letter of each word to uppercase.
Input
The input data contains multiple test instances, each of which is a line of English sentences with a length of not more than 100.
Output

Please output the English sentences that have been rewritten as required.

(1) method One/* All rights reserved.  * File name: Test.cpp * Chen Dani * Completion date: May 21, 2015 * Version number: v1.0 * * #include <iostream> #include <cstdio>using namespace    Std;int Main () {char a[100];        while (gets (a)) {int i;        A[0]=char (A[0]-32);        for (i=0;a[i]!= '; i++) {if (a[i]== ') A[i+1]=char (a[i+1]-32);        } for (i=0;a[i]!= '; i++) {cout<<a[i];    } cout<<endl; } return 0;} (2) method two #include<iostream> #include <cstdio> using namespace std;     int main () {char a[100];     int i;         while (gets (a)) {if (a[0]>= ' a ' &&a[0]<= ' z ') a[0]-=32;                 for (i=0; a[i]!= '; i++) {if (a[i]== ' &&a[i+1]>= ' a ' &&a[i+1]<= ' Z ')         a[i+1]-=32;         } for (i=0; a[i]!= '; i++) {cout<<a[i];     } cout<<endl; } return 0;  }

Learning experience: Do not neglect some small details, maybe he is the key to the overall impact, to be rigorous and careful, and continue to work hard!


C + + Brush title--1938: Capitalize the first letter

Related Article

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.