UVa1584 - Circular Sequence

简介: UVa1584 - Circular Sequence
#include <iostream>#include <string>#include <fstream>#include <vector>#include <algorithm>usingnamespacestd;
voidsolve(strings);
intmain()
{
#ifndef ONLINE_JUDGEifstreamfin("d:\\OJ\\uva_in.txt");
streambuf*old=cin.rdbuf(fin.rdbuf());
#endifintt;
cin>>t;
while (t--) {
strings;
cin>>s;
solve(s);
    }
#ifndef ONLINE_JUDGEcin.rdbuf(old);
#endifreturn0;
}
voidsolve(strings)
{
vector<string>vStr;
vStr.push_back(s);
for (size_ti=1, len=s.length(); i<len; i++) {
stringtmp;
tmp.append(s, i, len-i);
tmp.append(s, 0, i);
vStr.push_back(tmp);
    }
sort(vStr.begin(), vStr.end());
cout<<vStr.front() <<endl;
}
目录
相关文章
|
5月前
|
Python
Regular Expression
【7月更文挑战第1天】
37 1
|
Java Unix Shell
Regular Expressions (9)
基于POSIX BRE & ERE
185 0
Regular Expressions (9)
Triangular Collection思维
题目描述 Call a set of positive integers triangular if it has size at least three and, for all triples of distinct integers from the set, a triangle with those three integers as side lengths can be constructed. Given a set of positive integers, compute the number of its triangular subsets.
126 0
|
算法
HDOJ 1202 The calculation of GPA
HDOJ 1202 The calculation of GPA
122 0
LeetCode 622:设计循环队列 Design Circular Queue
LeetCode 622:设计循环队列 Design Circular Queue 首先来看看队列这种数据结构: 队列:先入先出的数据结构 在 FIFO 数据结构中,将首先处理添加到队列中的第一个元素。
972 0
AtCoder Regular Contest 069 D
D - Menagerie Time limit : 2sec / Memory limit : 256MB Score : 500 points Problem Statement Snuke, who loves animals, built a zoo.
1072 0