公共字串计算
来源:互联网 发布:怎么设计淘宝店铺模板 编辑:程序博客网 时间:2024/05/22 17:04
import java.util.*;public class Main{public static void main(String[] args) {Scanner scan = new Scanner(System.in);String str1 = scan.next().toLowerCase();String str2 = scan.next().toLowerCase();if(str1.length() < str2.length())getLen(str1,str2);elsegetLen(str2, str1);}private static void getLen(String str1, String str2) {int [] a = new int[str2.length()];Arrays.fill(a, 0);for (int i = 0; i < str2.length(); i++) {for (int j = 0; j < str1.length(); j++) {if(str2.charAt(i)==str1.charAt(j))a[i]=1;}}StringBuffer sb = new StringBuffer();for (int i = 0; i < a.length; i++) {sb.append(a[i]);}String s = sb.toString();String[] result = s.split("0");int max = 0;for (int i = 0; i < result.length; i++) {if(result[i].length() > max)max = result[i].length();}System.out.println(max);}}
0 0
- 公共字串计算1
- 公共字串计算
- 公共字串计算
- 公共字串计算
- 公共字串计算
- 公共字串计算
- 公共字串计算
- 华为OJ: 公共字串计算
- 华为上机 公共字串计算
- [华为oj]计算公共字串
- 华为oj 公共字串计算
- 华为oj 公共字串计算
- 计算最长公共数字串个数
- 华为OJ——公共字串计算
- 华为OJ 初级:公共字串计算
- 华为OJ——公共字串计算
- 【华为OJ】公共字符字串计算
- 华为OJ——公共字串计算
- @class的基本使用
- ACM经典算法之图论
- Hello JSP!——指令元素之taglib篇
- 自定义Notification~~
- C#程序开发中经常遇到的10条实用的代码
- 公共字串计算
- OCUI界面设计:表格视图-高级使用
- C++例程20150818-001
- hdu 1869 六度分离
- hadoop 环境搭建
- 打印 0 1 字符串(五位)
- iOS 调用相册或摄像头后状态栏消失解决办法
- 使用CameraBridgeViewBase时setDisplayOritention问题
- autorelease 的基本使用