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 ...
随机推荐
- <hdu - 1272> 小希的迷宫 并查集问题 (注意特殊情况)
本题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1272 Problem Description: 上次Gardon的迷宫城堡小希玩了很久(见Probl ...
- linux下使用autoconf制作Makefile
第一步:常用工具安装:正所谓:"工欲善其事,必先利其器".我们常用的工具主要有GNU AutomakeGNU AutoconfGNU m4GNU Libtool1.查看自己系统中是 ...
- Passing Reference by value
今天查bug的时候,遇到一个问题,一个Dictionary<int[],string>数据结构,在使用key取它的value时: var tempVar = _dic[key]; 发生崩溃 ...
- .Net 生成二维码【超简易,仅供学习】
1,首先下载DotNetBarcode.dll文件 下载地址: http://dl.downyi.com/dotnetbarcode_dll.rar 2,调用方式 string path = @&qu ...
- 【转】【Egit】如何将eclipse中的项目上传至Git
1.下载egit插件 打开Eclipse,git需要eclipse授权,通过网页是无法下载egit的安装包的.在菜单栏依次打开eclipse→help→install new software→add ...
- asp.net时间范围查询
1.首先要查询类表中的一个时间段,要明确我的数据库中只有一个时间字段,我们先将他拆分一下. if ($("#news_OpenTime").val() != "" ...
- C# 导出Word
导出word文档(无模版): using Microsoft.Office.Interop.Word; public static string CreateWordFile(CaseVM model ...
- Memcache(1)
一.缓存套路 原文地址:http://coolshell.cn/articles/17416.html Scaling Memcached at Facebook 好些人在写更新缓存数据代码时,先删除 ...
- C#中使用like和in参数传值
like 参数string strSql = "select * from Person.Address where City like '%'+ @add + '%'";SqlP ...
- LWP::UserAgent介绍3 -> cookie设置
use LWP::UserAgent; use HTTP::Cookies; my $ua = LWP::UserAgent->new; $ua->cookie_jar(HTTP::Coo ...