import java.util.Scanner; public class Main { /** * @BoyHonest */ public static void main(String[] args) { Scanner input = new Scanner(System.in); int N = input.nextInt(); int i = input.nextInt(); int j = input.nextInt(); //同行 for (int j2 = 1; j2 <= N; j2++) { for (int k = 1; k <= N; k++) { if (j2 == i) { System.out.print("(" + i + "," + k + ")"); } } } System.out.println(); //同列 for (int k = 1; k <= N; k++) { for (int k2 = 1; k2 <= N; k2++) { if (k2 == j) { System.out.print("(" + k + "," + j + ")"); } } } System.out.println(); //左上到右下 for (int j2 = 1; j2 <=N; j2++) { for (int k = 1; k <=N; k++) { if ((k-j2)==(j-i)) { System.out.print("(" + j2 + "," + k+ ")"); } } } System.out.println(); //左下到右上 for (int j2 = N; j2>=1; j2--) { for (int k = N; k >=1; k--) { if ((j2+k)==(i+j)) { System.out.print("(" + j2 + "," + k+ ")"); } } } } }
解题思路:四种情况一种一种讨论
注意事项:
参考代码:
0.0分
0 人评分
1014题解浏览:524 |
核桃的数量 (C语言代码)浏览:893 |
2005年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:636 |
矩阵的对角线之和 (C语言代码)浏览:1401 |
筛排处理 (C语言代码)浏览:830 |
【魔板】 (C++代码)浏览:1235 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:725 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:801 |
母牛的故事 (C语言代码)浏览:504 |
Pascal三角 (C++代码)浏览:749 |