nyoj308-Substring
#include<stdio.h>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
int t,i,j;
scanf("%d",&t);
while(t--)
{
string s1,s2,s3;
cin>>s1;
s2=s1;
int ma=;
int len=s1.size();
reverse(s2.begin(),s2.end());
for(i=; i<len; i++)
{
for(j=; j<=len-i; j++)
{
string::size_type pos=s2.find(s1.substr(i,j));
if(pos!=string::npos&&ma<j)
{
ma=j;
s3=s1.substr(i,j);
}
} }
cout<<s3<<endl;
} }
nyoj308-Substring的更多相关文章
- LeetCode[3] Longest Substring Without Repeating Characters
题目描述 Given a string, find the length of the longest substring without repeating characters. For exam ...
- 最长回文子串-LeetCode 5 Longest Palindromic Substring
题目描述 Given a string S, find the longest palindromic substring in S. You may assume that the maximum ...
- POJ3693 Maximum repetition substring [后缀数组 ST表]
Maximum repetition substring Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9458 Acc ...
- [LeetCode] Longest Substring with At Least K Repeating Characters 至少有K个重复字符的最长子字符串
Find the length of the longest substring T of a given string (consists of lowercase letters only) su ...
- substring的用法
public String substring(int beginIndex, int endIndex) 返回一个新字符串,它是此字符串的一个子字符串.该子字符串从指定的 beginIndex 处开 ...
- jQuery之常用且重要方法梳理(target,arguments,slice,substring,data,trigger,Attr)-(一)
1.jquery data(name) data() 方法向被选元素附加数据,或者从被选元素获取数据. $("#btn1").click(function(){ $(" ...
- leetcode--5. Longest Palindromic Substring
题目来自 https://leetcode.com/problems/longest-palindromic-substring/ 题目:Given a string S, find the long ...
- C#和Java中的Substring()
吐槽-使用清理软件整理电脑要注意,不要清理的"太狠",不然你会受伤的! C#中的Substring() 示例 实现代码 using System;using System.Coll ...
- JavaScript中的slice,splice,substr,substring,split的区别
万恶的输入法,在sublime中会显示出繁体字,各位看官见谅. 1.slice()方法:该方法在数组和string对象中都拥有. var a = [1,2,3,4,5,6]; var s = 'thi ...
- sql server中substring的用法
SQL 中的 substring 函数是用来截取一个栏位资料中的其中一部分. 例如,我们需要将字符串'abdcsef'中的'abd'给提取出来,则可用substring 来实现: ,) 结果: 'ab ...
随机推荐
- Python学习之旅(二十八)
Python基础知识(27):常用内建模块(Ⅲ) 1.urlblib urllib提供了一系列用于操作URL的功能 url是统一资源定位符,对可以从互联网上得到的资源的位置和访问方法的一种简洁的表示, ...
- 如何使用onclick方式添加多个事件回调函数
通过给onclcik包裹一个函数进行上下文的切换与参数的传递: function addClcikEvent(el, fn){ if(el.onclick){ var _back = el.oncli ...
- gitlab提交代码
cd existing_foldergit initgit remote add origin http://10.26.1.9/root/yunlian.gitgit add .git commit ...
- C# 封装winio.dll 驱动级按键鼠标操作模拟
using System;using System.Collections.Generic;using System.Text;using System.Runtime.InteropServices ...
- SQL Server 索引自动组织维护
公司的一个产品中的数据库,几个热点表因为主键和索引设计不合理,造成索引碎片过大,影响性能. 我尝试新建了一个索引碎片整理的定时任务,用于维护索引锁片和统计信息. 具体的过程如下: 本文原创,转发请表明 ...
- Coroutines declared with async/await syntax is the preferred way of writing asyncio applications. For example, the following snippet of code (requires Python 3.7+) prints “hello”, waits 1 second, and
小结: 1.异步io 协程 Coroutines and Tasks — Python 3.7.3 documentation https://docs.python.org/3/library/a ...
- html form禁止表单回车自动提交(通常原因是为在ajax提交前、后进行js判断控制)
@*onkeydown事件用于禁止回车自动提交form,这样就不经过js控制跳转*@ <form action="/Account/CheckPsw" method=&quo ...
- redis分布式锁的具体应用
1.关于redis分布式锁,有个setIfAbsent: 即如果没有设置,会添加分布式锁,并返回true; 2.redis分布式锁有个轮询过程: / * @param key redis键 * @pa ...
- Ubuntu 使用命令行连接无线网
一.查看可以使用的无线网: nmcli dev wifi 二.连接无线网: nmcli dev wifi connect ‘essid’(网络名称) password ‘password’(密码) 可 ...
- docker容器与镜像
就像cad图层概念 数据卷就是为了完成数据持久化操作