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 ...
随机推荐
- 【反射】Java反射机制
Class 1.Class是一个类,一个描述类的类(也就是描述类本身),封装了描述方法的Method,描述字段的Filed,描述构造器的Constructor等属性 2.对象照镜子后(反射)可以 ...
- 线性回归的Cost function实现
此处使用Octave来实现 线性方程的代价函数: 代价函数: X 是测试值,假设用矩阵表示为 为了方便用矩阵计算我们把X加一列 1 : 同时 那么h( ...
- JS高级——原型链
构造函数 构造函数是特殊的函数,里面没有returen返回值 new的过程中,会自动将对象返回,不需要return new的过程中,会执行函数中的代码,会将创建的对象赋值给构造函数中的this 基本概 ...
- Ajax——异步基础知识(一)
基础概念 1.异步请求可以做到偷偷向服务器发送请求,而页面却不刷新 2.get异步请求传递参数是通过url追加键值对的方式 3.post异步请求比较特殊,需要设置请求的类型 User-Agent:浏览 ...
- JS——缓慢动画封装
在知道如何获取内嵌式和外链式的标签属性值之后,我们再次封装缓慢动画: 单个属性 <!DOCTYPE html> <html> <head lang="en&qu ...
- GridView动态计算高度
// 动态加载GridView 高度 public static void setListViewHeightBasedOnChildren(MyGridView myGridView) { List ...
- CNN结构:色温-冷暖色的定义和领域区分(一)
转自知乎和百度百科:从零开始学后期 (色温的奥秘) 文章: 冷暖色区分?冷暖肤色适用于那些色系的彩妆? 文章:干货 |如何判断人体色冷暖?如何判断色彩冷暖?(值得收藏研读!) -蒜苗的回答 ...
- HDU_1063_Exponentiation_大数
Exponentiation Time Limit: 2000/500 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
- 抓包工具Fiddler及Charles
一.抓包工具介绍 1.charles抓包如何抓取手机端数据包(安卓手机) (1)获取pc的IP地址 (2)打开charles里的[Proxy]-[Proxy setting],设置端口号,默认为888 ...
- nuxt https
我用的模板是nxut-express,版本是:1.4.2.服务器:阿里云.一.申请免费证书:网站能通过https访问,首先得申请https证书,付费的阿里云上有售卖的,一年几千块.免费的可以通过cer ...