解题思路:
注意事项:
参考代码:
import java.util.Scanner; public class test1255 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int count = sc.nextInt(); int[][] num = new int[count][count]; int min = 99999; for (int i = 0; i < count; i++) { num[0][i] = sc.nextInt(); min = Math.min(min, num[0][i]); } int sum = 0; int minindex = 0; for (int i = 0; i < num.length; i++) { if (min == num[0][i]) { minindex = i; break; } } int x = minindex; for (int i = 0; i < num.length - 1;) { int n = x - 1; int m = x + 1; if (n < 0) { n = count - i - 1; } else if (n >= count - i) { n = 0; } if (m < 0) { m = count - i - 1; } else if (m >= count - i) { m = 0; } sum += num[i][n] * num[i][x] * num[i][m]; min = 9999; i++; for (int j = 0; j < num.length - i; j++) { if (j < x) { num[i][j] = num[i - 1][j]; } else { num[i][j] = num[i - 1][j + 1]; } min = Math.min(min, num[i][j]); } for (int q = 0; q < num.length - i; q++) { if (min == num[i][q]) { x = q; } } } System.out.println(sum); } }
0.0分
0 人评分
C二级辅导-同因查找 (C语言代码)浏览:705 |
多输入输出练习1 (C语言代码)浏览:1219 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:611 |
C语言程序设计教程(第三版)课后习题6.8 (C语言代码)浏览:798 |
C语言程序设计教程(第三版)课后习题1.6 (C语言代码)浏览:689 |
简单的a+b (C语言代码)浏览:560 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:729 |
C语言程序设计教程(第三版)课后习题8.6 (C语言代码)浏览:856 |
C语言程序设计教程(第三版)课后习题6.4 (C语言代码)浏览:381 |
C二级辅导-计负均正 (C语言代码)浏览:664 |