题解 | #牛牛的排序#

牛牛的排序

https://www.nowcoder.com/practice/26a0c92e9266443887a3bf81aff8e188

#include <stdio.h>
void sort(int *array,int n){
    int i,j;
    for(i=0;i<n-1;i++){
        int flag=0;
        for(j=0;j<n-1-i;j++){
            if(array[j]>array[j+1]){
                int temp = array[j];
                array[j]=array[j+1];
                array[j+1]=temp;
                flag=1;
            }
        }
        if(flag=0) break;
    }
}

int main() {
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    sort(a,n);
    for(int i=0;i<n;i++){
        printf("%d ",a[i]);
    }
    return 0;
}

全部评论

相关推荐

秋招到现在0offer,给各位985✌️丢脸了,不想再实习了,女朋友前几天还跟我忽然替分手了,搞得职场情场双失意😭虽然现在每天的工作就是坐着,闲得蛋疼,但打算润了准备考公了😡
迷茫的大四🐶:别慌,分析一波: 1.985学历,不脱腿,些许加分 2.有实习,说明具有一定实力和经验 3.女友离去,未来道路没有顾虑,放心前行 4.依旧年轻,拥有大好年华 加油,佬,不要被一时阴霾遮蔽双眼
实习心态崩了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务