问题描述:
对N个整数(数据由键盘输入)进行升序排列。
这里采用五个数。
代码如下:
#include<iostream>
#include<vector>
using namespace std;
int main() {
int a[5],t;
for (int i = 0; i < 5; i++) {
cin >> a[i];
}
for (int i = 1; i <= 4; i++) {
for (int j = 0; j <= 4-i; j++) {
if (a[j] > a[j + 1]) {
t = a[j + 1];
a[j + 1] = a[j];
a[j] = t;
}
}
}
for (int i = 0; i < 5;i++) {
cout << a[i] << " ";
}
}
// 4 6 3 5 9 ;
标签:int,namespace,冒泡排序,++,升序,include
From: https://www.cnblogs.com/drip3775/p/17353745.html