HUST 1339 Reversal(字符串)
题目链接
题解:将每个单词倒置,可以用char数组,然后用空格分隔,这里用的是string和stringstream。
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <cstring>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;
//#define LOCAL int main()
{
#ifdef LOCAL
freopen("in.txt", "r", stdin);
#endif // LOCAL
//Start
int N;
cin>>N;
while(N--)
{
int t;
cin>>t;
getchar();
string s,sss;
getline(cin,s);
stringstream ss(s);
int i=;
while(ss>>sss)
{
string::iterator it=sss.end()-;
if(i++!=)printf(" ");
while(it!=sss.begin())
{
cout<<*it;
it--;
}
cout<<*it;
}
printf("\n");
}
return ;
}
HUST 1339 Reversal(字符串)的更多相关文章
- zoj1151 zoj1295 Word Reversal 字符串的简单处理
Word Reversal Time Limit: 2 Seconds Memory Limit:65536 KB For each list of words, output a line ...
- HUST 1328 String (字符串前缀子串个数 --- KMP)
题意 给定一个字符串S,定义子串subS[i] = S[0..i],定义C[i]为S中subS[i]的数量,求sigma(C[i])(0<=i<N). 思路 我们以子串结尾的位置来划分阶段 ...
- zoj 1151 Word Reversal(字符串操作模拟)
题目连接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1151 题目描述: For each list of words ...
- HUST 1404 Hamming Distance(字符串)
Hamming Distance Description Have you ever heard of the Hamming distance. It is the number of positi ...
- Word Reversal (简单字符串处理)
题目描述: For each list of words, output a line with each word reversed without changing the order of th ...
- HUST 1010 The Minimum Length (字符串最小循环节)
题意 有一个字符串A,一次次的重写A,会得到一个新的字符串AAAAAAAA.....,现在将这个字符串从中切去一部分得到一个字符串B.例如有一个字符串A="abcdefg".,复制 ...
- ZOJ 1151 Word Reversal反转单词 (string字符串处理)
链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=151 For each list of words, output a l ...
- HUST 1352 Repetitions of Substrings(字符串)
Repetitions of Substrings Description The “repetitions” of a string S(whose length is n) is a maximu ...
- LA4671 K-neighbor substrings(FFT + 字符串Hash)
题目 Source http://acm.hust.edu.cn/vjudge/problem/19225 Description The Hamming distance between two s ...
随机推荐
- [读书笔记]python3.5实现socket通讯(UDP)
UDP连接: 无连接,从一个端向另一端发送独立的数据分组 使用UDP连接的客户-服务器程序: UDPServer.py import socket serverPort = 50009 serverS ...
- ASP.NET用户控件操作ASPX页面
定义一个不含数据的事件处理方法 用户控件 public event EventHandler Click; protected void Button1_Click(object sender, Ev ...
- [河南省ACM省赛-第三届] BUYING FEED (nyoj 248)
#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> us ...
- java实现的简单词法分析器
一个简单的词法分析器 词法分析(Lexical Analysis) 是编译的第一阶段.词法分析器的主要任务是读入源程序的输入字符.将他们组成词素,生成并输出一个词法单元序列,每个词法单元对应一个词素. ...
- Ubuntu 16.04上Docker使用手记
一.Docker Hub的使用Docker Hub是Docker官方维护的仓库,里面已经包含了很多的镜像,一般我们的需求直接在官方仓库搜索就可以得到解决.在官方的公共仓库中我们无需登录就可以进行镜像的 ...
- 学习任务在继续...css...
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- 如何在无法直接用VS启动代码时如何调试代码
1. 普通情况下对进程Attach就可以调试. 2. 但是在一些情况下直接attach并无法调试,例如安装程序installer, 这样使用如下的调试方法即可调试安装程序. System.Diagno ...
- Scala分号推断
看这样段代码,Scala会把它当作两个语句,x 和 +y,如果想把它作为一个语句,可以把它们放在括号里(x+y) x +y 或者也可以把 + 放在行末,也正因为此,串接类似于 + 这样的中缀操作符的时 ...
- Python基础(五)-函数
函数: 1.定义与使用: def 函数名(参数): "函数_文档字符串" 函数体 ... return [表达式] ## def:表示函数的关键字 函数名:函数名称,根据函数名调用 ...
- LoadRunner日志(归档记录,以便自己查阅)
1.当设置迭代次数大于1时,回放从第二次迭代开始发生错误 这种现象多是由于在"Run-time Setting"的"Browse Emulation"的设置中, ...