ASCII码排序

来源:互联网 发布:中文.商城域名骗局 编辑:程序博客网 时间:2024/06/10 20:12

题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=4

import java.util.Scanner;public class Main {    public static void main(String[] args) {        Scanner sc = new Scanner(System.in);        int number = sc.nextInt();        while (number-- != 0) {            String s = sc.next();            char temp;            char a1;            char a2;            char a3;            a1 = s.charAt(0);            a2 = s.charAt(1);            a3 = s.charAt(2);            for (int i = 0; i < 3; i++) {                if (a1 > a2) {                    temp = a1;                    a1 = a2;                    a2 = temp;                }                if (a2 > a3) {                    temp = a2;                    a2 = a3;                    a3 = temp;                }            }            System.out.print(a1);            System.out.print(' ');            System.out.print(a2);            System.out.print(' ');            System.out.println(a3);        }    }}


0 0
原创粉丝点击