zoukankan      html  css  js  c++  java
  • 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=0;
            int  len=s1.size();
            reverse(s2.begin(),s2.end());
            for(i=0; i<len; i++)
            {
                for(j=1; 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;
        }
    
    }
  • 相关阅读:
    053-157
    053-496
    053-128
    053-167
    053-250
    053-674
    离职申请
    日记


  • 原文地址:https://www.cnblogs.com/nr1999/p/9072785.html
Copyright © 2011-2022 走看看