解题思路:
注意事项:
参考代码:
import java.util.Scanner;
public class C1017 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
int n = sc.nextInt();
for(int i = 0; i <= n; i++){
print(i);
}
}
sc.close();
}
public static void print(int x){
int sum = 0;
for(int i = 1; i < x; i++){
if(x%i == 0){
sum += i;
}
}
if(sum == x && x != 0){
System.out.print(x + " its factors are ");
for(int i = 1; i < x; i++){
if(x%i == 0){
System.out.print(i + " ");
}
}
System.out.println();
}
}
}
0.0分
0 人评分
A+B for Input-Output Practice (VI) (C语言代码)浏览:563 |
【蟠桃记】 (C语言代码)浏览:2219 |
点我有惊喜!你懂得!浏览:4106 |
C语言程序设计教程(第三版)课后习题7.5 (C语言代码)浏览:579 |
C语言程序设计教程(第三版)课后习题12.3 (C语言代码)浏览:820 |
不知道哪里错了浏览:1141 |
【回文数(二)】 (C++代码)浏览:865 |
C语言程序设计教程(第三版)课后习题8.3 (Java代码)浏览:1367 |
数组输出 (C语言代码)--此题的题目描述有问题浏览:1814 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:575 |