1601. AntiCAPS

Time limit: 0.5 second

Memory limit: 64 MB
The blonde Angela has a new whim: internet chats. Of course, as any blonde, shewrites her messages using the upper case. You are the moderator of Angela'sfavorite chat and you're fed up with her upper-case messages. The problemis
that Angela does not respond to your warnings. You decided to write a simpleantiCAPS corrector, which would make Angela's messages readable.
The correction rules are very simple:

  1. Sentences in a message consist of words, spaces and punctuation marks.
  2. Words consist of English letters.
  3. Sentences end with a full stop, exclamation mark, or question mark.
  4. The first word of each sentence must start with a capital letter, and all otherletters of the sentence must be lowercase.

Input

You are given Angela's message, which consists of uppercase English letters,spaces, line breaks and punctuation marks: full stops, commas, dashes, colons, exclamationand question marks. Total length of message is not exceeding
10000 symbols.

Output

Output the corrected message.

Sample

input output
HI THERE!
HOW DID YOU KNOW I AM A BLONDE?
Hi there!
How did you know i am a blonde?

Problem Author: Denis Musin

Problem Source: IX USU Open Personal Contest (March 1, 2008)

解析:注意两点:

1.每一个句子以‘.’,‘?’和‘!’结尾。每一个句子开头字符都要换成大写。

2.换行不算句子结尾的标志。

下面提供两组測试例子:

input1:

HELLO. I AM ANJELA! AND YOU?

I AM BLONDE.



output1:

Hello. I am anjela! And you?

I am blonde.

input2:

HHHHHHHHHH? SDSDFSDF! SFSDF. SDFAF

HKLLKSDJOI

output2:

Hhhhhhhhhh? Sdsdfsdf! Sfsdf. Sdfaf

hkllksdjoi

AC代码:

#include <bits/stdc++.h>
using namespace std; int main(){
#ifdef sxk
freopen("in.txt", "r", stdin);
#endif // sxk string s;
int flag = 1;
while(getline(cin, s)){
int n = s.size();
for(int i=0; i<n; i++){
if(flag){
if(s[i] >= 'A' && s[i] <= 'Z') flag = 0;
}
else{
if(s[i] >= 'A' && s[i] <= 'Z') s[i] += ('a' - 'A');
else if(s[i] == '.' || s[i] == '?' || s[i] == '!') flag = 1;
}
}
cout<<s<<endl;
}
return 0;
}

URAL 1601. AntiCAPS (strings)的更多相关文章

  1. URAL 1297 Palindrome(Manacher)

    The “U.S. Robots” HQ has just received a rather alarming anonymous letter. It states that the agent ...

  2. URAL 1024 Permutations(LCM)

    题意:已知,可得出 P(1) = 4, P(2) = 1, P(3) = 5,由此可得出 P(P(1)) = P(4) = 2. And P(P(3)) = P(5) = 3,因此.经过k次如上变换, ...

  3. URAL 1119. Metro(BFS)

    点我看题目 题意  : 这个人在左下角,地铁在右上角,由很多格子组成的地图,每一条边都是一条路,每一条边都是100米.还有的可以走对角线,问你从起点到终点最短是多少. 思路 : 其实我想说一下,,,, ...

  4. HDU 1075 What Are You Talking About (strings)

    What Are You Talking About Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 102400/204800 K ...

  5. URAL 1137Bus Routes (dfs)

    Z - Bus Routes Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Subm ...

  6. URAL 1291 Gear-wheels(BFS)

    Gear-wheels Time limit: 1.0 secondMemory limit: 64 MB - Arny! What happened with coordinator? Bad wo ...

  7. URAL 1242 Werewolf(DFS)

    Werewolf Time limit: 1.0 secondMemory limit: 64 MB Knife. Moonlit night. Rotten stump with a short b ...

  8. URAL 1244. Gentlemen (DP)

    题目链接 题意 : 给出一幅不完全的纸牌.算出哪些牌丢失了. 思路 : 算是背包一个吧.if f[j]>0  f[j+a[i]] += f[j];然后在记录一下路径. #include < ...

  9. URAL 1224. Spiral (规律)

    1224. Spiral Time limit: 1.0 second Memory limit: 64 MB A brand new sapper robot is able to neutrali ...

随机推荐

  1. Zookeeper概念学习系列之zookeeper的数据模型

    1.层次化的目录结构,命名符合常规文件系统规范. 2.每个节点在zookeeper中叫做znode,并且有其有一个唯一的路径标识. 3.znode中的数据可以有多个版本,比如某一路径下存有多个数据版本 ...

  2. 2018.10.9 logstash启动慢的问题解决

    问题描述: 线上部署logstash 启动非常缓慢,达到了10分钟 问题解决 忍无可忍 网上资料基本都是熵过低导致jruby启动缓慢的问题,需要安装haveged 参考https://www.jian ...

  3. windows server2003 多用户登陆问题解决办法

    windows server2003 多用户登陆问题解决办法 Windows Server远程登陆默认情况下只允许同时有两个用户登陆,超过两个用户会提示"超出最大连接数". 要解决 ...

  4. Java_Web三大框架之Hibernate+jsp+HQL分页查询

    分页查询无处不在.使用Hibernate+jsp+HQL进行分页查询. 第一步:编写房屋实体类和House.hbm.xml映射. /* * 房屋实体类 */ public class House { ...

  5. Centos6.7 安装Naigos教程

    Centos6.7 安装Naigos教程参考文档:https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/quickst ...

  6. centOS7创建python虚拟环境

    参考: 非常棒的2篇博客 https://www.centos.bz/2018/05/centos-7-4-%E5%AE%89%E8%A3%85python3%E5%8F%8A%E8%99%9A%E6 ...

  7. CORNERSTONE在线敏捷开发工具这么强大,除了推荐,我别无选择

    刚接到一个新项目,完全找不到思路, 怎么办? 任务分工不明,成员相互推诿, 怎么办? 编制的工作计划,老挨产品经理批, 怎么办? 时间短,任务紧,进度与时间两难控制, 怎么办? ...... 别着急, ...

  8. Python总结2

    时间:25日上午'''列表定义:在[]内,可以存放多个任意类型的值,并以逗号隔开''''students=['sb','2b']print(students[1])student_info=['min ...

  9. vue刷新本页面

    顶层app.vue页面 <template> <div id="app"> <router-view v-if="isRouterAlive ...

  10. DOCKER - POD操作

    强制删除 Terminating 的pod kubectl delete  -n <namespace> <pod podname> --grace-period=0 --fo ...