URAL 1601. AntiCAPS (strings)
1601. AntiCAPS
Memory limit: 64 MB
that Angela does not respond to your warnings. You decided to write a simpleantiCAPS corrector, which would make Angela's messages readable.
- Sentences in a message consist of words, spaces and punctuation marks.
- Words consist of English letters.
- Sentences end with a full stop, exclamation mark, or question mark.
- The first word of each sentence must start with a capital letter, and all otherletters of the sentence must be lowercase.
Input
10000 symbols.
Output
Sample
input | output |
---|---|
HI THERE! |
Hi there! |
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
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)的更多相关文章
- URAL 1297 Palindrome(Manacher)
The “U.S. Robots” HQ has just received a rather alarming anonymous letter. It states that the agent ...
- 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次如上变换, ...
- URAL 1119. Metro(BFS)
点我看题目 题意 : 这个人在左下角,地铁在右上角,由很多格子组成的地图,每一条边都是一条路,每一条边都是100米.还有的可以走对角线,问你从起点到终点最短是多少. 思路 : 其实我想说一下,,,, ...
- 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 ...
- URAL 1137Bus Routes (dfs)
Z - Bus Routes Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Subm ...
- URAL 1291 Gear-wheels(BFS)
Gear-wheels Time limit: 1.0 secondMemory limit: 64 MB - Arny! What happened with coordinator? Bad wo ...
- URAL 1242 Werewolf(DFS)
Werewolf Time limit: 1.0 secondMemory limit: 64 MB Knife. Moonlit night. Rotten stump with a short b ...
- URAL 1244. Gentlemen (DP)
题目链接 题意 : 给出一幅不完全的纸牌.算出哪些牌丢失了. 思路 : 算是背包一个吧.if f[j]>0 f[j+a[i]] += f[j];然后在记录一下路径. #include < ...
- URAL 1224. Spiral (规律)
1224. Spiral Time limit: 1.0 second Memory limit: 64 MB A brand new sapper robot is able to neutrali ...
随机推荐
- 【LeetCode】105 & 106 Construct Binary Tree from (Preorder and Inorder) || (Inorder and Postorder)Traversal
Description: Given arrays recording 'Preorder and Inorder' Traversal (Problem 105) or 'Inorder and ...
- [转]linux之diff 命令
转自:http://www.cnblogs.com/peida/archive/2012/12/12/2814048.html diff 命令是 linux上非常重要的工具,用于比较文件的内容,特别是 ...
- Sqoop架构(四)
Sqoop 架构是非常简单的,它主要由三个部分组成:Sqoop client.HDFS/HBase/Hive.Database. 下面是Sqoop 的架构图 (1)用户向 Sqoop 发起一个命令之后 ...
- 大话设计模式--DI(依赖注入)
1.背景 想象一个场景:有个功能通过某个参数决定了路由到不同的方法上或者几个方法模块可以自由搭配,咋办?一般人会对每个方法写一个helper(比如SendMessageForEmail.SendMes ...
- Razor的使用
Razor可以识别尖括号,且关键词是@,默认情况下会对输出的html代码进行转义 1.C#代码 用 @ 加 中括号 包起来 @{ ; i < ; i++) { <h3>C#语句块要用 ...
- 淘宝ip地址库接口会导致TTFB时间变长,网站打开速度变慢
前一段时间闲来无事发现别人的网站上有显示当前用户城市的功能,就自己也整了一个 这是淘宝ip地址库调用方法 然后问题就出现了,网站打开速度慢的要死 用F12发现是TTFB太慢,然后百度了,发现了问题的原 ...
- Android 从服务器获取时间戳转换为年月日
用JAVA相关类转换.代码如下: Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(NumberUtils.ge ...
- 升级Xcode或 MacOS编译iOS出现resource fork, Finder information, or similar detritus not allowed
很久没有在网上留下足迹了,冒个泡吧 最近升级了Xcode,编译之前的一个项目是出现问题,问题结尾如下: resource fork, Finder information, or similar de ...
- SV creation order
SystemVerilog Instance Worlds When generating an UVM testbench and in particular the DUT - testbench ...
- perf-perf stat用户层代码分析
perf_event 源码分析 前言 简单来说,perf是一种性能监测工具,它首先对通用处理器提供的performance counter进行编程,设定计数器阈值和事件,然后性能计数器就会在设定事件发 ...