//数组查表法(根据键盘录入索引,查找对应星期)
import java.util.Scanner;
class Arr_chabiao {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
char [] arr = {'一','二','三','四','五','六','日'};
char c = week(char [] arr, a);
System.out.println("星期"+c);
}
public static char week(char [] arr, int b){
for (int i = 0;i<arr.length ;i++ ) {
if (b==i+1) {
return arr[i];
}
}
}
}
如果给我一个数组 让我找其中一个元素 可以找到吗
|
|