题解 | #牛牛的排序#

牛牛的排序

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

using namespace std;

void sort(int *array,int n) {
    if(array==NULL) return;
    if(n <= 1) return;
    for(int i=0;i<n-1;++i){
        for(int j=0;j<n-1;++j){
            if(array[j]>array[j+1])
                swap(array[j], array[j+1]);
        }
    }
        for(int i=0;i<n;++i){
        cout<<array[i]<<" ";
        }
        return;
    
}

int main(){
    int n;
    cin>>n;
    int array[n];
    for(int i=0;i<n;i++){
        cin>>array[i];
    }
    sort(array,n);
}
全部评论

相关推荐

野猪不是猪🐗:我assume that你must技术aspect是solid的,temperament也挺good的,however面试不太serious,generally会feel style上不够sharp
面试吐槽bot
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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