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. 如何查看jdk的版本

    (1)WINDOWS环境下 实验环境:WIN7 64bit 操作指令:cmd命令下输入“java -version” 参考如下:JDK1.7 (2).LINUX环境下 实验环境:CentOS 5.6 ...

  2. 338 Counting Bits Bit位计数

    给定一个非负整数 num. 对于范围 0 ≤ i ≤ num 中的每个数字 i ,计算其二进制数中的1的数目并将它们作为数组返回.示例:比如给定 num = 5 ,应该返回 [0,1,1,2,1,2] ...

  3. Java系列学习(十二)-开始Eclipse

    1.用Eclipse来写一个HelloWorld (1)选择工作空间 工作空间其实就是我们写的源代码所在的目录 (2)创建一个Java项目 [File-New-Java Project] (3)创建包 ...

  4. reactnative(1) - RefreshControl 使用案例

    'use strict'; import React, { Component } from 'react'; import { AppRegistry, ScrollView, StyleSheet ...

  5. 查询数据表行数 然后循环查找表 添加数据到ITEMS

    ;i<tbBiao.Rows.Count;i++) { string TableName = (tbBiao.Rows[i]["Table"]).ToString(); tb ...

  6. CAD绘制一个对齐标注(com接口VB语言)

    主要用到函数说明: _DMxDrawX::DrawDimAligned 绘制一个对齐标注.详细说明如下: 参数 说明 DOUBLE dExtLine1PointX 第一条界线开始点X值 DOUBLE ...

  7. 聊聊JS动画库:Velocity.js

    前言 又到了炎热的7月,很久没有更新技术文章了,原因是上月月底实习结束,从公司离职.然后最近在弄自己的项目和考驾照,为了下次公司的应聘做准备,送别了女朋友到外地,哩哩啦啦半个月把一切事情都办妥后,还是 ...

  8. PAT_A1107#Social Clusters

    Source: PAT A1107 Social Clusters (30 分) Description: When register on a social network, you are alw ...

  9. Day 13 进程和线程

    进程和线程 今天我们使用的计算机早已进入多CPU或多核时代,而我们使用的操作系统都是支持“多任务”的操作系统,这使得我们可以同时运行多个程序,也可以将一个程序分解为若干个相对独立的子任务,让多个子任务 ...

  10. 27.6 Parallel的静态For,Foreach和Invoke方法

    static void Main(string[] args) { //for (int i = 0; i < 10000; i++) // DoWork(i); //Parallel.For( ...