牛牛的身高错在哪里了?
代码:
import java.util.Scanner;
public class Main {
public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); int[] arr = new int[t]; for (int i = 0; i < t; i++) { arr[i] = Integer.parseInt(sc.next()); int ch = 10; while (arr[i] / ch > 0) { int y = arr[i] % ch; if (y >= ch /2) { arr[i] = arr[i] + (ch - y); } ch *= 10; } System.out.println(arr[i]); } }
}