解题思路:
注意事项:
参考代码:
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[][]ns=new int[3][3]; for (int i = 0; i < ns.length; i++) { ns[i][0]=sc.nextInt(); ns[i][1]=sc.nextInt(); ns[i][2]=sc.nextInt(); } int res=1; int sum=ns[0][0]+ns[0][1]+ns[0][2]; for (int i = 0; i < ns.length; i++) { if (sum==ns[i][0]+ns[i][1]+ns[i][2]&&sum==ns[0][i]+ns[1][i]+ns[2][i]) { res=1; } else { res=0; System.out.println(res); return; } } if (sum==ns[0][0]+ns[1][1]+ns[2][2]&&sum==ns[0][2]+ns[1][1]+ns[2][0]) { res=1; } else { res=0; System.out.println(res); return; } System.out.println(res); } }
0.0分
1 人评分
2005年春浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:828 |
字符串的输入输出处理 (C语言代码)浏览:2024 |
C二级辅导-计负均正 (C语言代码)浏览:598 |
C语言程序设计教程(第三版)课后习题8.6 (C语言代码)浏览:582 |
矩形面积交 (Java代码)浏览:1224 |
C语言程序设计教程(第三版)课后习题8.6 (C语言代码)浏览:538 |
C语言程序设计教程(第三版)课后习题7.1 (C语言代码)浏览:1229 |
C语言训练-大、小写问题 (C语言代码)浏览:614 |
C语言程序设计教程(第三版)课后习题8.8 (C语言代码)浏览:1434 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:328 |