hiho一下第107周《Give My Text Back》
题目链接:传送门
题目大意:给你多组格式不标准的字符串句子,要你恢复到标准格式(单词中间只有一个空格或者一个逗号一个空格,句子的首字母大写其他小写,遇到回车也要换行)
题目思路:直接按题意模拟,注意几个标记变量的状态改变就行
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <stack>
#include <cctype>
#include <queue>
#include <string>
#include <vector>
#include<functional>
#include <set>
#include <map>
#include <climits>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define fi first
#define se second
#define ping(x,y) ((x-y)*(x-y))
#define mst(x,y) memset(x,y,sizeof(x))
#define mcp(x,y) memcpy(x,y,sizeof(y))
using namespace std;
#define gamma 0.5772156649015328606065120
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define N 30005
#define maxn 100005
typedef pair<int,int> PII;
typedef long long LL; char ch;
string st=""; int main(){
int i,j,x,y;
int dax=,kong=;
while(cin>>noskipws>>ch){
if(isalpha(ch)){
ch=tolower(ch);
if(dax){
if(kong)st+=" ";
st+=toupper(ch);
dax=;
}
else{
st+=ch;
}
kong=;
}
else{
if(ch==','){
if(st[st.length()-]==' ')st[st.length()-]=',';
else st+=',';
st+=" ";
kong=;
}
else if(ch=='.'){
if(st[st.length()-]==' ')st[st.length()-]='.';
else st+='.';
kong=;
dax=;
}
else if(ch==' '||ch=='\t'){
if(kong){
st+=" ";
kong=;
}
}
else if(ch=='\n'){
if(st!=""){
int len=st.length();
for(i=len-;i>=;--i)if(st[i]!=' ')break;
st=st.substr(,i+);
cout<<st<<endl;
dax=;kong=;
st="";
}
}
}
}
return ;
}
hiho一下第107周《Give My Text Back》的更多相关文章
- 圆内,求离圆心最远的整数点 hiho一下第111周 Farthest Point
		// 圆内,求离圆心最远的整数点 hiho一下第111周 Farthest Point // 思路:直接暴力绝对T // 先确定x范围,每个x范围内,离圆心最远的点一定是y轴两端的点.枚举x的范围,再 ... 
- hiho一下 第115周:网络流一•Ford-Fulkerson算法 (Edmond-Karp,Dinic,SAP)
		来看一道最大流模板水题,借这道题来学习一下最大流的几个算法. 分别用Edmond-Karp,Dinic ,SAP来实现最大流算法. 从运行结过来看明显SAP+当前弧优化+gap优化速度最快. hi ... 
- hiho一下 第一百零七周 Give My Text Back(微软笔试题)
		题目1 : Give My Text Back 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 To prepare for the English exam Littl ... 
- 【hiho一下第77周】递归-减而治之 (MS面试题:Koch Snowflake)
		本题是一道微软面试题,看起来复杂,解出来会发现其实是一个很简单的递归问题,但是这道题的递归思路是很值得我们反复推敲的. 原题为hihocoder第77周的题目. 描述 Koch Snowflake i ... 
- hiho一下 第207周
		题目1 : The Lastest Time 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 What is latest time you can make with ... 
- hiho一下第128周 后缀自动机二·重复旋律5
		#1445 : 后缀自动机二·重复旋律5 时间限制:10000ms 单点时限:2000ms 内存限制:512MB 描述 小Hi平时的一大兴趣爱好就是演奏钢琴.我们知道一个音乐旋律被表示为一段数构成的数 ... 
- 【hiho一下】第一周 最长回文子串
		题目1:最长回文子串 题目原文:http://hihocoder.com/contest/hiho1/problem/1 [题目解读] 题目与 POJ 3974 palindrome 基本同样.求解最 ... 
- Solution: 最近公共祖先·一  [hiho一下 第十三周]
		题目1 : 最近公共祖先·一 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Ho最近发现了一个神奇的网站!虽然还不够像58同城那样神奇,但这个网站仍然让小Ho乐在其中 ... 
- hiho一下十六周 RMQ-ST算法
		RMQ-ST算法 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi和小Ho在美国旅行了相当长的一段时间之后,终于准备要回国啦!而在回国之前,他们准备去超市采购一些当 ... 
随机推荐
- jq的form验证
			jQuery(document).ready(function(){ $('#cform img.contact-loader').hide(); $('#cform').submit(functio ... 
- macbook使用“终端”远程登录linux主机
			登录mac系统后,依次打开顶部菜单,“前往” -> “应用程序” -> “实用工具” -> “终端”,如下图: 在打开的终端页面,输入如下代码: ssh user@hostnam ... 
- 监听用户的后退键,解决部分浏览器回退的bug
			监听用户的后退键,解决部分浏览器回退的bug $(document).keydown(function (event) { // 监听backspace键 if (event.keyCode == 8 ... 
- EF(EntityFramework) Migrations 迁移
			1.开启程序包管理器控制台 2.安装EntityFramework PM> Install-Package EntityFramework 3.启用迁移 PM> Enable-Migr ... 
- Android Studio公布到Jcenter
			1.前言 拥抱开源.热爱开源,将我们觉得不错的代码开源到gihtub.将我们的库公布到jcenter\mevan等. 2.准备工作 2.1 准备 申请仓库账号 注意model为android libr ... 
- Application Architecture Determines Application  Performance
			 Application Architecture Determines Application Performance Randy Stafford AppliCATion ARCHiTECTuR ... 
- TLS线程局部存储
			0x01 TLS (Thread Local Storage) 为线程单独提供的私有空间 0x02 gcc中的隐式TLS使用方法 隐式TLS __thread int number; 显式TLS pt ... 
- 河南省第七届ACM程序设计大赛赛后总结
			我们学校ACM集训开始于4月5号(清明节),5月25日在郑州解放军信息工程大学举办,集训耗时50天,但是感觉效果还行,但是也不是太好:我们也已经尽力了,虽然说只拿了个银牌,每份收获的背后,都会有辛勤的 ... 
- WEB前端面试题 分别使用2个、3个、5个DIV画出一个大的红十字
			<!DOCTYPE html> <!--两个DIV--> <html> <body> <div style="width:100%;he ... 
- javascript的弹框
			学习js最先了解到的两种种简单测试手段就是alert("blah");和console.log("blah");了. 除了alert之外,js还有两种弹框 co ... 
