Fare丶梦


私信TA

用户名:126913199

访问量:22534

签 名:

等  级
排  名 119
经  验 4127
参赛次数 0
文章发表 50
年  龄 22
在职情况 学生
学  校
专  业

  自我简介:

解题思路:

答案正确格式正确,不知为何显示答案错误



注意事项:





参考代码:

import java.util.Scanner;


public class Main {

       

        public static void In(){

                Scanner sc = new Scanner(System.in);

                int[] array = new int[10];

                for(int i = 0;i<10;i++){

                        array[i] = sc.nextInt();

                }

                deal(array);

        }

        public static void deal(int[] array){

                final int temp = array[0];

                final int temp1 = array[9];

                int num = 0;

                int num1 = 0;

                for(int i=0;i<10;i++){

                        if(array[0]>array[i]){

                                array[0] = array[i];

                                num=i;

                        }

                        if(array[9]<array[i]){

                                array[9] = array[i];

                                num1=i;

                        }

                }

                array[num] = temp;

                array[num1] = temp1;

                Out(array);

        }

        public static void Out(int[] array){

                for(int i=0;i<10;i++){

                        System.out.print(array[i]+" ");

                }

        }

        public static void main(String[] arg){

                In();

        }

}


 

0.0分

0 人评分

  评论区