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