public class CSDN{ public static void main(String[] args){ CSDN tmp = new CSDN(); System.out.println(tmp.encode("abc"));//(1) System.out.println(tmp.encode("efg")); System.out.println(tmp.encode("abc"));//the same as (1) System.out.println(tmp.encode("beb"));//the same as (1) System.out.println(tmp.encode("aaaaaaa")); } public int encode(String str){ return (str.charAt(0)+str.charAt(str.length()-1))*str.length()%100; } }
或者是Integer.parseInt("5") ;
public class CSDN{
public static void main(String[] args){
CSDN tmp = new CSDN();
System.out.println(tmp.encode("abc"));//(1)
System.out.println(tmp.encode("efg"));
System.out.println(tmp.encode("abc"));//the same as (1)
System.out.println(tmp.encode("beb"));//the same as (1)
System.out.println(tmp.encode("aaaaaaa"));
} public int encode(String str){
return (str.charAt(0)+str.charAt(str.length()-1))*str.length()%100;
}
}
这个可以实现。