解题思路:
注意事项:
参考代码:
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 人评分
C二级辅导-进制转换 (C语言代码)浏览:788 |
C二级辅导-进制转换 (C语言代码)浏览:820 |
破解简单密码 (C语言代码)浏览:1761 |
C语言程序设计教程(第三版)课后习题6.11 (C语言代码)for循环浏览:1108 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:608 |
小九九 (C语言描述,不看要求真坑爹)浏览:984 |
矩形面积交 (C语言代码)浏览:1294 |
整除问题 (C语言代码)浏览:518 |
C语言程序设计教程(第三版)课后习题7.5 (C语言代码)浏览:673 |
C语言程序设计教程(第三版)课后习题10.2 (C语言代码)浏览:535 |