2011. 7. 28. 23:30

//2011 04
//Daun..
//포인터를 가장 많이 사용하게되는, 이제는 거의 외워써 쓰는 Swap함수!
#include <iostream>
using namespace std;
void swap (int *pa, int *pb)
{
 int temp;
 temp=*pa;
 *pa=*pb;
 *pb=temp;
}
int main ()
{
 int num1=10, num2=20;

 cout << num1 << " " << num2 << endl;
 swap (&num1, &num2);

 cout << num1 << " " << num2;
 return 0;
}

'Code > c/c++' 카테고리의 다른 글

[C++]poker  (0) 2011.09.03
[Code] 유클리드 알고리즘(Euclid Algorism)  (0) 2011.08.29
[C++ Code]주소값출력하기  (0) 2011.07.28
[C++ Code]재귀함수  (0) 2011.07.28
[C++ Code]야구게임  (0) 2011.07.28
Posted by I_co