C++
c++ swap(값 교환)
Dev_Jen
2023. 1. 7. 00:37
반응형
#include <iostream>
using namespace std;
void swap(int &a, int &b){
int temp;
temp = a;
a = b;
b = temp;
}
int main(){
int i = 10;
int j = 20;
cout << i << " " << j << endl;
swap(i,j);
cout << i << " " << j << endl;
}
반응형