[20-04-30][Self-test 24]Java SecondMax
2021-02-02 04:15
标签:一个 class style 下标 test string pac secondmax public 结果如下: 第二大的数下标为:7 [20-04-30][Self-test 24]Java SecondMax 标签:一个 class style 下标 test string pac secondmax public 原文地址:https://www.cnblogs.com/mirai3usi9/p/12811422.html 1 package test_5_1;
2
3 public class SecondMax {
4
5 public static void main(String[] args) {
6
7 /** 给定一个整型数组,数组成员10个,求该数组中第二大的数的下标 */
8 int[] numArr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0};
9 int[] copyNumArr = new int[numArr.length];
10
11 for (int i = 0; i ) {
12 copyNumArr[i] = numArr[i];
13 }
14
15
16 for (int i = 0; i ) {
17 for (int j = i + 1; j ) {
18 if (numArr[i] numArr[j]) {
19 int temp = numArr[i];
20 numArr[i] = numArr[j];
21 numArr[j] = temp;
22 }
23 }
24 }
25
26 for (int i = 0; i ) {
27 if (numArr[i] == copyNumArr[1]) {
28 System.out.println("第二大的数下标为:" + i);
29 return;
30 }
31 }
32
33
34 }
35
36 }
下一篇:三、python变量
文章标题:[20-04-30][Self-test 24]Java SecondMax
文章链接:http://soscw.com/index.php/essay/49799.html