이것이 c++이다 연습문제 1-6
1-6 다음과 같은 int 배열을 오름차순으로 정렬한 후 화면에 결과를 출력하는 프로그램을 작성하세요. 정렬 방법은 상관없습니다. 단, 화면에 배열 내용을 출력할 때는 반드시 '범위 기반 for문'을 사용해야 합니다. int aList[5] = {40, 10, 20, 50, 30}; 답: #include "pch.h" #include #include using namespace std; #define max 5 void Swap(int &a, int &b) { int nTmp = a; a = b; b = nTmp; } int _tmain(int argc, _TCHAR* argv[]) { int aList[max] = { 40,10, 20, 50, 30 }; for (int i = 0; i