您当前的位置: 首页 >  c++

鱼儿-1226

暂无认证

  • 0浏览

    0关注

    1100博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

VC++整数(排序)

鱼儿-1226 发布时间:2020-08-24 14:29:19 ,浏览量:0

输入描述:
输入包括两行,第一行包括一个整数n(1 ≤ n ≤ 50),即玩家的人数
第二行n个整数x[i](0 ≤ x[i] ≤ 100000),即每个玩家写下的整数。
输出描述:
输出一个整数,表示赢得游戏的那个玩家获得的最大数字是多少。
输入
3
9638 8210 331
输出
3689

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

import java.util.Arrays;

import java.util.Scanner;

  

public class Main {

    public static void main(String[] args) {

        // TODO Auto-generated method stub

        Scanner scanner = new Scanner(System.in);

        int n = scanner.nextInt();

        int max = -1;

        for(int i = 0; i != n; i++){

            String s = scanner.next();

            char temp[] = s.toCharArray();

            max = Math.max(max, hebing(temp));

        }

        System.out.print(max);        

    

    public static int hebing(char a[]){

        Arrays.sort(a);

        int temp1 = Integer.parseInt(new String(a));

        return temp1;

    }

}

关注
打赏
1604459285
查看更多评论
立即登录/注册

微信扫码登录

0.0391s