posts - 1, comments - 0, trackbacks - 0, articles - 0
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          2008年4月14日

          import java.lang.*;

          class MaxSameSubString {

           private String str1="ashfjeudccckfjgiccccccjgurhd";
           private String str2="dhfurjcccckgoymjdhccfi";
           
           public void getResualt()
           {
            String max="";
            for(int i=0;i<str2.length();i++)
            {
             String temp1=str2.substring(i);
             for(int y=temp1.length()-1;y>=0;y--)
             {
              String temp2=temp1.substring(0,y);
              if(str1.indexOf(temp2)!=-1 && temp2.length()>max.length())
               max=temp2;
             }
            }
            
            System.out.println(max);
           }

           public static void main(String [] args)
           {
            MaxSameSubString msss=new MaxSameSubString();
            msss.getResualt();
           }
          }

          posted @ 2008-04-14 21:59 黑馬與櫻桃樹 閱讀(944) | 評論 (0)編輯 收藏

          主站蜘蛛池模板: 贡山| 聂荣县| 西乌珠穆沁旗| 阿尔山市| 蛟河市| 手机| 湖南省| 忻城县| 宜宾县| 遂昌县| 青阳县| 海晏县| 乐山市| 金塔县| 株洲市| 尼木县| 青龙| 马公市| 米脂县| 洛浦县| 沁水县| 灯塔市| 临漳县| 多伦县| 禄劝| 灌阳县| 东兴市| 宁波市| 土默特右旗| 班玛县| 南城县| 灵寿县| 普安县| 江阴市| 从江县| 新晃| 石狮市| 呼图壁县| 兴文县| 镇坪县| 油尖旺区|