题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3129

The Brave Sir Robin took a short walk in a dark forest where rabbits did stalk. a ray of sunlight made him jump from his own shadow with A FACE AS PALE AS CHALK.
the brave sir robin took a short walk in a dark forest where rabbits did stalk. A ray of sunlight made him jump from his own shadow with a face as pale as chalk.
题意:
就是把‘.’,‘ !‘, ‘?‘ 后面的第一个字母变为大写,其余的全小写!
PS:
注意‘.’,‘ !‘, ‘?‘ 后面有多个‘ ‘, ‘(‘ , ‘)‘的情况!
然后就是换行也相当于是一个空格!
代码如下:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
char s[1017];
int tt = 0;
while(gets(s))
{
tt++;
int len = strlen(s);
for(int i = 0; i < len; i++)
{
if(i == 0 && tt > 1)
{
while(s[i]==' ' || s[i]=='(' || s[i]==')')
{
i++;
if(i >= len)
break;
}
s[i] = toupper(s[i]);
}
else if(s[i]=='.' || s[i]=='!' || s[i]=='?')
{
i++;
while(s[i]==' ' || s[i]=='(' || s[i]==')')
{
i++;
if(i >= len)
break;
}
s[i] = toupper(s[i]);
}
else
{
s[i] = tolower(s[i]);
}
}
printf("%s\n",s);
}
return 0;
}
/*
The Brave Sir Robin took a short walk in a dark forest where rabbits did stalk. a
ray of sunlight made him jump from his own shadow with A FACE AS PALE AS CHALK.
The Brave Sir Robin took a short walk in a dark forest where rabbits did stalk. a
ray of sunlight made him jump from his own shadow with A FACE AS PALE AS CHALK.
*/HDU 3129 The Brave Sir Robin’s cAsE cOrReCtOr(字符串处理)
原文地址:http://blog.csdn.net/u012860063/article/details/40828609