码迷,mamicode.com
首页 > 编程语言 > 详细

HDU 2000 ASCII码排序

时间:2018-09-17 13:30:46      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:read   组成   esc   toc   next   har   static   java   new   

题目链接:HDU 2000

Description

输入三个字符后,按各字符的ASCII码从小到大的顺序输出这三个字符。

Input

输入数据有多组,每组占一行,有三个字符组成,之间无空格。

Output

对于每组输入数据,输出一行,字符中间用一个空格分开。

Sample Input

qwe
asd
zxc

Sample Output

e q w
a d s
c x z

代码

import java.util.*;
class Main
{
    public static void main(String [] args){
        Scanner read=new Scanner(System.in);
        char []a=new char[3];
        while(read.hasNext()){
            a=read.next().toCharArray();
            
            for(int i=0;i<3;i++)
                for(int j=0;j<3;j++)
                if((int)a[i]<(int)a[j]){
                char ch=a[i];
                a[i]=a[j];
                a[j]=ch;
                
            }
            System.out.println(a[0]+" "+a[1]+" "+a[2]);
        }
    }
}

HDU 2000 ASCII码排序

标签:read   组成   esc   toc   next   har   static   java   new   

原文地址:https://www.cnblogs.com/Titordong/p/9661468.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!