考虑当第一个字符是空格的时候
#include<iostream>
#include<string>
#include<string.h>
using namespace std;
void main()
{
int i,j;
string ch;
while(getline(cin,ch))
{
i=0;
if(ch[i]>='a'&&ch[i]<='z')
{
ch[0]=ch[0]-'a'+'A';
++i;
}
while(ch[i]!='\0')
{
if(ch[i]==' '&&ch[i+1]<='z'&&ch[i+1]>='a')
{
++i;
if(ch[i]>='a'&&ch[i]<='z'&&ch[i]!='\0')
ch[i]=ch[i]-'a'+'A';
}
++i;
}
cout<<ch<<endl;
}
}