HDOJ 1040 As Easy As A+B

Problem Description
These days, I am thinking about a question, how can I get a problem as easy as A+B? It is fairly difficulty to do such a thing. Of course, I got it after many waking nights.
Give you some integers, your task is to sort these number ascending (升序).
You should know how easy the problem is now!
Good luck!

Input
Input contains multiple test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. Each test case contains an integer N (1<=N<=1000 the number of integers to be sorted) and then N integers follow in the same line.
It is guarantied that all integers are in the range of 32-int.

Output
For each case, print the sorting result, and one line one case.

Sample Input
2
3 2 1 3
9 1 4 7 2 5 8 3 6 9

Sample Output
1 2 3
1 2 3 4 5 6 7 8 9

就是排序!按照升序排

import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while(t-->0){
            int m = sc.nextInt();
            int[] a = new int[m];
            for(int i=0;i<m;i++){
                a[i]=sc.nextInt();
            }

            for(int i=0;i<m-1;i++){
                for(int j=i+1;j<m;j++){
                    if(a[j]<a[i]){
                        int temp=a[j];
                        a[j]=a[i];
                        a[i]=temp;
                    }
                }
            }

            System.out.print(a[0]);
            for(int i=1;i<m;i++){
                System.out.print(" "+a[i]);
            }
            System.out.println();

        }

    }

}
时间: 2024-09-18 05:36:41

HDOJ 1040 As Easy As A+B的相关文章

HDOJ 1076 An Easy Task(闰年计算)

Problem Description Ignatius was born in a leap year, so he want to know when he could hold his birthday party. Can you tell him? Given a positive integers Y which indicate the start year, and a positive integer N, your task is to tell the Nth leap y

HDOJ 2055 An easy problem

Problem Description we define f(A) = 1, f(a) = -1, f(B) = 2, f(b) = -2, - f(Z) = 26, f(z) = -26; Give you a letter x and a number y , you should output the result of y+f(x). Input On the first line, contains a number T.then T lines follow, each line

HDOJ(HDU) 2132 An easy problem

Problem Description We once did a lot of recursional problem . I think some of them is easy for you and some if hard for you. Now there is a very easy problem . I think you can AC it. We can define sum(n) as follow: if i can be divided exactly by 3 s

HDOJ(HDU) 2123 An easy problem(简单题...)

Problem Description In this problem you need to make a multiply table of N * N ,just like the sample out. The element in the ith row and jth column should be the product(乘积) of i and j. Input The first line of input is an integer C which indicate the

HDOJ 2057 A + B Again

Problem Description There must be many A + B problems in our HDOJ , now a new one is coming. Give you two hexadecimal integers , your task is to calculate the sum of them,and print it in hexadecimal too. Easy ? AC it ! Input The input contains severa

嘎嘎 噶 噶爱国-JQuery easy UI 在国内一般什么样规模的公司使用才会付费呢?

问题描述 JQuery easy UI 在国内一般什么样规模的公司使用才会付费呢? 在国内使用JQuery easy UI付费的单位一般是什么级别的啊?有知道的亲么,说下呗,问题很急,求问答,一旦被采纳,以身相许!!!!!!!!!!!!!!

Curtis Fuller - Sliding Easy

Lee Morgan, Trumpet:Hank Mobley, Tenor Sax:Curtis Fuller, Trombone:Tommy Flanagan, Piano:Paul Chambers, Bass:Elvin Jones, Drums 1. Down home 2. Down home (Alt tk) 3. C.T.A. 4. When lights are low 5. I wonder where our love has gone 6. Bongo bop 7. Bi

不能启动 Easy Config时如何创建一个新的网络服务

创建|网络 如果你发现Easy Config不能启动,而原有的网络服务正常使用,那么可以通过以下的方法进行创建.修改.删除网络服务.1 创建(新增加一个网络服务) 在你Oracle安装目录下..\Oracle\Ora81\NETWORK\ADMIN下找到tnsnames.ora,用notepad或其他的文本编辑器打开,会看到以下内容  # E:\ORACLE\ORA81\NETWORK\ADMIN\TNSNAMES.ORA Configuration File:E:\Oracle\Ora81\N

VBScript - The Easy Stuff - Page 2

vbscript   VBScript - The Easy Stuff - Page 2 Chris Assenza February 5, 2001 VariablesI think everyone knows what a variable is, but to be safe, a variable is a little chunk of memory in which a value of varying type (like characters and numbers) can