다음 C++ 프로그램의 실행 결과로 옳은 것은?
#include <iostream>
using std::cout;
using std::endl;
void swap1(int *a, int *b) {
int temp = *a; *a = *b; *b = temp;
}
void swap2(int &a, int &b) {
int temp = a; a = b; b = temp;
}
void main() {
int c = 10, d = 30;
swap1(&c, &d);
cout << c << " " << d << endl;
swap2(c, d);
cout << c << " " << d << endl;
}- ①10 30
- ②10 3010 30 30 10
- ③30 10
- ④30 1010 30 30 10
선지를 골라 바로 채점해 보세요.
정답 ③
출처: 인사혁신처 공개 기출(공공데이터포털, 이용허락 제한 없음)