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. [转]linux 下 join命令总结

    转自:http://blog.chinaunix.net/uid-20754793-id-177777.html 有两个文件需要合并,开始写了脚本实现,忽然发现join命令能够完全替代,总结了一下jo ...

  2. Xml的读取

    using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace WebAp ...

  3. Android视频截图

    本文介绍如何获取视频中某个时间点的数据 调用以下方法即可,特别注意,在获取图片时的参数单位为微秒,不是毫秒 如果错用了毫秒会一直获取第一帧的画面 /** * 获取某个时间点的帧图片 * * @para ...

  4. Android项目实战_手机安全卫士程序锁

    ###1.两个页面切换的实现1. 可以使用Fragment,调用FragmentTransaction的hide和show方法2. 可以使用两个布局,设置visibility的VISIABLE和INV ...

  5. Java_Web三大框架之Hibernate+HQL语言基础

    12.1 HQL语言基础Hibernate查询语言为HQL(Hibernate Query Language),可以直接使用实体类名及属性.HQL语法类似于SQL,有SQL的关键词如select.fr ...

  6. css的基本单词

    <border>边框 border边框 <text>文本 text文本 <indent>缩进 indent缩进 <align>对齐方式 align对齐方 ...

  7. 【转载】HTTP 响应头与状态码

    原文地址:https://segmentfault.com/a/1190000006689786 HTTP Response Header 响应头域允许服务器传递不能放在状态行的附加信息,这些域主要描 ...

  8. IOS7 APP 升级的10个TIP 建议

    There is no way to preserve the iOS 6 style status bar layout. The status bar will always overlap yo ...

  9. Vector 和 Array 区别

    1:array 定义的时候必须定义数组的元素个数;而vector 不需要:且只能包含整型字面值常量,枚举常量或者用常量表达式初始化的整型const对象, 非const变量以及需要到运行阶段才知道其值的 ...

  10. HDU 1465(错排公式)

    不容易系列之一 题意: 一个人要寄n个信封,结果装错了.信纸的编号为1到n,信封的编号为1到n,信纸的编号不能和信封的编号一样,全都不能一样. 思路:错排公式. D(n)表示n件信封装错的所有的情况. ...