解题思路:
注意事项:
参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int count = 0; for (int i = 1; i <= n; i++) { String a = String.valueOf(i); for (int j = 0; j < a.length(); j++) { if (a.charAt(j)== '1') { count++; } } } System.out.println(count); } }
0.0分
0 人评分