#26219: 解答(C++)


weimolin222@gmail.com (林維摩)

School : 屏東市明正國中
ID : 128544
IP address : [180.176.69.238]
Last Login :
2021-09-26 21:03:25
d587. 參貳壹真好吃 -- jack1 | From: [180.176.69.238] | Post Date : 2021-07-24 19:40

#include<iostream>

using namespace std;

int main(){

int n;

cin>>n;

int num[n]={0};

for(int i=0;i<n;i++){

cin>>num[i];

}

for(int i=0;i<n;i++){

for(int i=0;i<n-1;i++){

if(num[i]>num[i+1]){

int b=0;

b=num[i];

num[i]=num[i+1];

num[i+1]=b;

}

}

}

for(int i=0;i<n;i++){

cout<<num[i]<<" ";

}

}

 
ZeroJudge Forum