`
bcyy
  • 浏览: 1951667 次
文章分类
社区版块
存档分类
最新评论

Timus 1601. AntiCAPS 修正大写句子

 
阅读更多

The blonde Angela has a new whim: internet chats. Of course, as any blonde, she writes her messages using the upper case. You are the moderator of Angela's favorite chat and you're fed up with her upper-case messages. The problem is that Angela does not respond to your warnings. You decided to write a simple antiCAPS corrector, which would make Angela's messages readable.
Problem illustration
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 other letters 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, exclamation and 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?

就是修正个全是大写的句子。

这里注意一点(as in codes' comment):

keep the state, because blonde would do anything, and put the comma, in one line, and start typing another line.


#include <string>
#include <iostream>
using namespace std;

void toLowerCase(string &s, bool &senBegin)
{
	for (unsigned i = 0; i < s.size(); i++)
	{
		if (' ' == s[i]) continue;
		if (senBegin) 
		{
			if ('A' <= s[i] && s[i] <= 'Z' || 'a' <= s[i] && s[i] <= 'z') 
			{
				s[i] = toupper(s[i]);
				senBegin = false;
			}
			continue;
		}
		if ('.' == s[i] || '?' == s[i] || '!' == s[i]) senBegin = true;
		s[i] = tolower(s[i]);
	}
}

int AntiCAPS1601()
{
	string s;
	bool senBegin = true;//keep the state, because blonde would do anything, and put the comma, in one line, and start typing another line.
	while (getline(cin, s))
	{
		toLowerCase(s, senBegin);
		cout<<s<<endl;
	}
	return 0;
}



分享到:
评论

相关推荐

    Times New Roman.TTF.rar

    在提供的压缩包中,我们看到有四款不同样式的Times New Roman字体文件:TIMES.TTF(常规)、TIMESBD.TTF(粗体)、TIMESI.TTF(斜体)和TIMESBI.TTF(粗体斜体)。这些不同的变体满足了设计师在文本表达时对于强调、...

    Times New Roman.ttf

    "Times New Roman.ttf"是与SMARTFORMS相关的字体文件,它在创建这些表单时可能会被用到。 首先,让我们深入了解SAP ABAP。ABAP(Advanced Business Application Programming)是SAP系统中的编程语言,用于开发企业...

    KITTI数据集00序列times.txt文件

    苦苦寻找的times文件,用于KITTI数据集SLAM测试 苦苦寻找的times文件,用于KITTI数据集SLAM测试 苦苦寻找的times文件,用于KITTI数据集SLAM测试

    Android Times Square.zip

    Android Times Square介绍: 效果不错的日历UI模块。可以设置成只能选择单个日期,或者可以选择多个不连续的日期,或者可以通过点击两个日期来选择之间连续的日期。并且可以将日历放到弹出的对话框中。   测试...

    KITTI数据集times序列的文本文档

    在SLAM应用中,`times.txt`文件可能包含了每个传感器数据帧的时间戳,这有助于精确地同步来自不同传感器的数据流。例如,它可能包含了每帧图像和LiDAR扫描的捕获时间。这些时间戳可以用于确保在进行特征匹配或运动...

    27Modern_Times_ExtraPack.rar

    27Modern_Times_ExtraPack.rar 27Modern_Times_ExtraPack.rar

    ( Times New Roman.rar

    2. TIMES.TTF - 这是 Times New Roman 的常规(Regular)样式,也是基本的字体文件。 3. TIMESI.TTF - 这表示 Times New Roman 的斜体(Italic)版本。 4. TIMESBI.TTF - 这是 Times New Roman 的粗斜体(Bold ...

    PyPI 官网下载 | mo-times-2.27.18331.tar.gz

    标题中的"PyPI 官网下载 | mo-times-2.27.18331.tar.gz"表明这是一个从Python Package Index(PyPI)官方源下载的软件包,名为"mo-times",版本号为2.27.18331,其格式是tar.gz。PyPI是Python开发者发布和获取开源库...

    Times

    "times.TTF"则是一个TrueType字体文件,包含了Times New Roman的所有字符和相关的排版信息,用户可以将其安装到计算机上,以便在各种应用程序中使用这种字体。 在IT实践中,了解和使用不同的字体对于设计师和开发...

    Times New Roman .fon

    Times New Roman .fon

    ttf-mscorefonts-installer.zip

    在Linux系统中,为了使matplotlib库能够正确地显示如Times New Roman这样的Microsoft Core Fonts,我们需要进行额外的配置。"ttf-mscorefonts-installer.zip"这个压缩包正是为了解决这个问题,它包含了安装这些字体...

    Python库 | mo-times-5.53.21241.tar.gz

    资源分类:Python库 所属语言:Python 资源全名:mo-times-5.53.21241.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    开源项目-djherbis-times.zip

    开源项目-djherbis-times.zip 是一个专门为Go语言编写的库,主要关注文件的时间属性管理。这个项目由djherbis开发,旨在为Go开发者提供访问和操作文件的访问时间(atime)、修改时间(mtime)、状态改变时间(ctime...

    cmd脚本-bat批处理-settimes.zip

    cmd脚本-bat批处理-settimes.zip

    B6_TimeS.rar_garch_garch stata

    标题中的"B6_TimeS.rar_garch_garch stata"暗示了这是一个与时间序列分析相关的项目,特别是使用了GARCH(Generalized Autoregressive Conditional Heteroskedasticity)模型,并且该分析是在STATA统计软件中进行的...

    IDEA链接MySQL报错08001和连接成功后不显示表的问题及解决方法

    Attempted reconnect 3 times. Giving up. 解决办法:在url后面拼接?serverTimezone=UTC 连接成功后数据库不显示表 通过设置解决: scheme选择当前使用的数据库 到此这篇关于IDEA链接MySQL报错08001和连接成功...

Global site tag (gtag.js) - Google Analytics