C++
선택정렬[오름차순]
2sac
2024. 10. 25. 16:14
#include <iostream>
#include <cstring>
using namespace std;
int main() {
int arr[5] = { 9,5,2,6,3 };
int temp = 0;
for (int y = 0; y < 5; y++) {
for (int x = y; x < 5; x++) {
if (arr[y] > arr[x]) {
temp = arr[y];
arr[y] = arr[x];
arr[x] = temp;
}
}
}
return 0;
}