一道求程序员女婿一道题的算法
public class Hello3 { // 添加public修饰符和类名
public static void main(String[] args) {
System.out.println("Hello World!");
int[] arr = new int[]{5,0,6,7,3,9,1,4};
int[] index = new int[]{6,0,2,1,3,6,7,0,2,5,4};
String Tel = "";
for(int i : index){
Tel += arr[i] + " ";
}
System.out.println("lianxifangshi:" + Tel);
}
}
保存为Hello3.java,编译javac Hello3.java,然后java Hello3
运行结果如下图所示