1到25个数用5乘5方格用java编写一个程序 横 数 斜都是65的和
答案:1 悬赏:50 手机版
解决时间 2021-03-26 16:23
- 提问者网友:酱爆肉
- 2021-03-25 19:47
1到25个数用5乘5方格用java编写一个程序 横 数 斜都是65的和
最佳答案
- 五星知识达人网友:患得患失的劫
- 2021-03-25 20:31
public class test{
public static void main(String[] args) {
for (int num1 = 1; num1 <= 25; num1++) {
for (int num2 = 1; num2 <= 25; num2++) {
for (int num3 = 1; num3 <= 25; num3++) {
for (int num4 = 1; num4 <= 25; num4++) {
for (int num5 = 1; num5 <= 25; num5++) {
for (int num6 = 1; num6 <= 25; num6++) {
for (int num7 = 1; num7 <= 25; num7++) {
for (int num8 = 1; num8 <= 25; num8++) {
for (int num9 = 1; num9 <= 25; num9++) {
for (int num10 = 1; num10 <= 25; num10++) {
for (int num11 = 1; num11 <= 25; num11++) {
for (int num12 = 1; num12 <= 25; num12++) {
for (int num13 = 1; num13 <= 25; num13++) {
for (int num14 = 1; num14 <= 25; num14++) {
for (int num15 = 1; num15 <= 25; num15++) {
for (int num16 = 1; num16 <= 25; num16++) {
for (int num17 = 1; num17 <= 25; num17++) {
for (int num18 = 1; num18 <= 25; num18++) {
for (int num19 = 1; num19 <= 25; num19++) {
for (int num20 = 1; num20 <= 25; num20++) {
for (int num21 = 1; num21 <= 25; num21++) {
for (int num22 = 1; num22 <= 25; num22++) {
for (int num23 = 1; num23 <= 25; num23++) {
for (int num24 = 1; num24 <= 25; num24++) {
for (int num25 = 1; num25 <= 25; num25++) {
if (num1+num2+num3+num4+num5==65&&num6+num7+num8+num9+num10==65
&&num11+num12+num13+num14+num15==65&&num16+num17+num18+num19+num20==65
&&num21+num22+num23+num24+num25==65&&num1+num6+num11+num16+num21==65
&&num2+num7+num12+num17+num22==65&&num3+num8+num13+num18+num23==65
&&num4+num9+num14+num19+num24==65&&num5+num10+num15+num20+num25==65
&&num1+num7+num13+num19+num25==65&&num5+num9+num13+num17+num21==65){
System.out.println(num1+" "+num2+" "+num3+" "+num4+" "+num5);
System.out.println(num6+" "+num7+" "+num8+" "+num9+" "+num10);
System.out.println(num11+" "+num12+" "+num13+" "+num14+" "+num15);
System.out.println(num16+" "+num17+" "+num18+" "+num19+" "+num20);
System.out.println(num21+" "+num22+" "+num23+" "+num24+" "+num25);
System.out
.println(" ");
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
没有输出结果,可能不存在这种情况
public static void main(String[] args) {
for (int num1 = 1; num1 <= 25; num1++) {
for (int num2 = 1; num2 <= 25; num2++) {
for (int num3 = 1; num3 <= 25; num3++) {
for (int num4 = 1; num4 <= 25; num4++) {
for (int num5 = 1; num5 <= 25; num5++) {
for (int num6 = 1; num6 <= 25; num6++) {
for (int num7 = 1; num7 <= 25; num7++) {
for (int num8 = 1; num8 <= 25; num8++) {
for (int num9 = 1; num9 <= 25; num9++) {
for (int num10 = 1; num10 <= 25; num10++) {
for (int num11 = 1; num11 <= 25; num11++) {
for (int num12 = 1; num12 <= 25; num12++) {
for (int num13 = 1; num13 <= 25; num13++) {
for (int num14 = 1; num14 <= 25; num14++) {
for (int num15 = 1; num15 <= 25; num15++) {
for (int num16 = 1; num16 <= 25; num16++) {
for (int num17 = 1; num17 <= 25; num17++) {
for (int num18 = 1; num18 <= 25; num18++) {
for (int num19 = 1; num19 <= 25; num19++) {
for (int num20 = 1; num20 <= 25; num20++) {
for (int num21 = 1; num21 <= 25; num21++) {
for (int num22 = 1; num22 <= 25; num22++) {
for (int num23 = 1; num23 <= 25; num23++) {
for (int num24 = 1; num24 <= 25; num24++) {
for (int num25 = 1; num25 <= 25; num25++) {
if (num1+num2+num3+num4+num5==65&&num6+num7+num8+num9+num10==65
&&num11+num12+num13+num14+num15==65&&num16+num17+num18+num19+num20==65
&&num21+num22+num23+num24+num25==65&&num1+num6+num11+num16+num21==65
&&num2+num7+num12+num17+num22==65&&num3+num8+num13+num18+num23==65
&&num4+num9+num14+num19+num24==65&&num5+num10+num15+num20+num25==65
&&num1+num7+num13+num19+num25==65&&num5+num9+num13+num17+num21==65){
System.out.println(num1+" "+num2+" "+num3+" "+num4+" "+num5);
System.out.println(num6+" "+num7+" "+num8+" "+num9+" "+num10);
System.out.println(num11+" "+num12+" "+num13+" "+num14+" "+num15);
System.out.println(num16+" "+num17+" "+num18+" "+num19+" "+num20);
System.out.println(num21+" "+num22+" "+num23+" "+num24+" "+num25);
System.out
.println(" ");
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
没有输出结果,可能不存在这种情况
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯