• HDU 2000 ASCII码排序


    题目链接: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]);
    		}
    	}
    }
    
  • 相关阅读:
    个人博客
    个人博客
    个人博客
    个人博客
    个人博客
    团队作业—个人记录
    4.21
    4.20
    4.19
    4.18
  • 原文地址:https://www.cnblogs.com/Titordong/p/9661468.html
Copyright © 2020-2023  润新知