HDU 2000 JAVA

来源:互联网 发布:改键盘 软件 编辑:程序博客网 时间:2024/06/16 00:26

Problem 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 sc= new Scanner(System.in);    while(sc.hasNext()){      String str=sc.next();      char [] a=str.toCharArray();int b;      int [] c=z(a);      Arrays.sort(c);      for(int i=0;i<c.length;i++){        if(i!=c.length-1){          System.out.print((char)c[i]+" ");        }else{          System.out.println((char)c[i]);        }      }    }  }  public static int[] z(char []a){    int []b=new int [a.length];    for(int i =0;i<a.length;i++){      b[i]=(int)a[i];    }    return b;  }}
0 0
原创粉丝点击