Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main() {
- int n, a[100];
- cout << "Nhap n: ";
- cin >> n;
- for (int i = 0; i < n; i++) {
- cout << "Nhap a[" << i << "] = ";
- cin >> a[i];
- }
- for (int i = 0; i < n - 1; i++)
- for (int j = i + 1; j < n; j++) {
- if (a[i] > a[j]) {
- int temp;
- temp = a[i];
- a[i] = a[j];
- a[j] = temp;
- }
- }
- cout << "Mang a sau khi sap xep:\n";
- for (int i = 0; i < n; i++) {
- cout << a[i] << ' ';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement