最近刷PAT上的练习题,遇到将未知位数的数倒序输出,思考两天有个可以的方法,望见解!
List<Integer> list = new ArrayList<Integer>();
while(sum > 0) {
int temp = sum % 10;
list.add(temp);
sum = sum / 10;
}
Collections.sort(list);
最近刷PAT上的练习题,遇到将未知位数的数倒序输出,思考两天有个可以的方法,望见解!
List<Integer> list = new ArrayList<Integer>();
while(sum > 0) {
int temp = sum % 10;
list.add(temp);
sum = sum / 10;
}
Collections.sort(list);