我尝试过使用System.out.print()
但这似乎并不想工作。我试图按递减顺序获取输出。它必须在for循环中吗?或者在我最后使用的public class EmployeeWorkHours {
public static void main(String[] args) {
Scanner turtle = new Scanner(System.in);
String[] calender = { "S", "M", "T", "W", "Th", "F", "S" };
System.out.println("How many Employee's do you have?: ");
int NUMBER_OF_EMPLOYEES = turtle.nextInt();
turtle.nextLine();
int [][]hours;
int[] totalHours= new int[NUMBER_OF_EMPLOYEES];
hours = new int[NUMBER_OF_EMPLOYEES][7];
String[] employee = new String[NUMBER_OF_EMPLOYEES];
// input for Names
for (int x = 0; x < (employee.length); x++) {
System.out.println("Name of Employee " + (x + 1) + ": ");
String name = turtle.nextLine();
employee[x] = name;
}
// input for Hours
for (int z = 0; z < employee.length; z++) {
System.out.println("Starting from Sunday, enter the hours Employee "+ (z + 1)+ " has worked each day (Make sure you seperate it by spaces): ");
for (int a = 0; a < 7; a++) {
hours[z][a] = turtle.nextInt();
}
turtle.nextLine();
}
// Print everything out
for (int i = 0; i < employee.length; i++) {
totalHours[i]=0;
for(int j=0; j<7; j ++){
totalHours[i] = totalHours[i]+hours[i][j];
}
System.out.println("Employee " + (i + 1) +" worked " + totalHours[i] + " hours");
}
}
}
中?
>>> idx, = np.where(a == 1)
>>> mask = np.logical_or.reduceat(np.isnan(a), idx)[:-1]
>>> np.diff(idx)[~mask]
array([4, 5])
答案 0 :(得分:0)
尝试
Collections.sort(arraylist, Collections.reverseOrder());
或者
Collections.sort(list);
Collections.reverse(list);
它还取决于您正在使用的集合的实现。
答案 1 :(得分:0)
尝试查看 this。
更具体地说,这部分链接
Comparator cmp = Collections.reverseOrder();
// sort the list
Collections.sort(list, cmp);
System.out.println("List sorted in ReverseOrder: ");
for(int i : list){
System.out.println(i+ " ");
}