zoukankan      html  css  js  c++  java
  • AC日记

    Problem Description

        给你N(N<=100)个数,请你按照从小到大的顺序输出。

    Input

        输入数据第一行是一个正整数N,第二行有N个整数。

    Output

        输出一行,从小到大输出这N个数,中间用空格隔开。

    Example Input

    5
    1 4 3 2 5

    Example Output

    1 2 3 4 5

    Hint

    #include <stdio.h>
    #include <stdlib.h>
    int main()
    {
        int N;
        int *num, i, j, temp;
        scanf("%d", &N);
        num=malloc(sizeof(int)*N);
    
        for(i=0; i<N; i++)
        scanf("%d", &num[i]);
    
        for(i=1; i<N; i++)
        for(j=0; j<N-i; j++)
        {
            if(num[j]>num[j+1])
            {
                temp=num[j+1];
                num[j+1]=num[j];
                num[j]=temp;
            }
        }
        for(i=0; i<N; i++)
        {
            if(i==0)
            printf("%d", num[i]);
            else
            printf(" %d", num[i]);
        }
    
    }
    

      

    作者:7oDo

    仅供参考,请勿抄袭。

    Hang Hang Hang !!!

  • 相关阅读:
    HDU 6034
    HDU 6047
    CodeForces 830B
    HDU 4972
    HDU 4408
    CodeForces 788B
    CodeForces 788A
    CodeForces 792C
    uva 1658 Admiral 最小费最大流
    hdu 5391 Zball in Tina Town 威尔逊定理
  • 原文地址:https://www.cnblogs.com/Jie-Fei/p/8297141.html
Copyright © 2011-2022 走看看