赛前十天——打印输入字符串的全排列&&cls(java实现)

package javaPractice;

import java.util.Scanner;

public class Contest13 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		arrange(s,0);
		sc.close();
	}
	
	public static void arrange(char[] s,int n) {
		if(n == s.length) {
			for(int i=0;i
package javaPractice;
//求两个字符串最大公共子序列的长度
public class Contest14 {
	public static void main(String[] args) {
		System.out.println(f("student","shear"));		
	}
	
	public static int f(String s1,String s2) {
		if(s1.length() == 0||s2.length() == 0) {
			return 0;
		}
		else if(s1.charAt(0) == s2.charAt(0)) {
			return f(s1.substring(1),s2.substring(1))+1;
		}
		else {
			return Math.max(f(s1.substring(1), s2),f(s1,s2.substring(1)));
		}
	}
}

 

你可能感兴趣的:(java,算法)