작성
·
150
2
void print(const int* array, const int length) {
for (int i = 0; i < length; ++i)
cout << array[i] << " ";
cout << endl;
}
int main() {
const int length = 5;int array[length]{ 3,1,2,5,4};
int tmp;
for (int i = 0; i < length; ++i) {
for (int j = 0; j < i; ++j) {
if (array[i] < array[j]) {
tmp = array[i];
array[i] = array[j];
array[j] = tmp;
print(array, length);
}
}
}
print(array, length);
return 0;
}