【发布时间】:2022-01-20 05:57:28
【问题描述】:
我对编程很陌生。我在 Programming Praxis 中发现了这个有趣的问题,并被困在如何获取整数的数字并将它们存储到数组中。
老实说,我不知道从哪里开始,我想学习如何在 Java 中做到这一点。
如果您有兴趣,这是我正在处理的问题的代码。
public class MyClass {
public static void main(String args[]) {
// Determine all three-digit numbers N having the property that N is divisible by 11, and N/11 is equal to the sum of the squares of the digits of N.
int num = 100;
int square_sum = 0;
int digit1 = 0;
int digit2 = 0;
int digit3 = 0;
while (num <= 999){
if (num % 11 == 0) { //if remainder == 0; the number is divisible by 11//
// We need to get the digits of int "num" and square them //
int arrayDigits[] = new int[3];
} else
num++;
}
}
}
【问题讨论】: