//7.6 指针和数组
//利用指针访问数组中元素
#include<iostream>
using namespace std;
//实现两个数字进行交换
//void swap01(int a,int b)
//{
// int temp = a;
// a = b;
// b = temp;
// cout << "swap01 a=" << a << endl;
// cout << "swap02 b=" << b << endl;
//}
//7.7 指针和函数
void swap02(int *p1, int *p2)
{
int temp = *p1;
*p1 = *p2;
*p2 = temp;
}
int main()
{
//1.值传递
int a = 10;
int b = 20;
//swap01(a, b);
swap02(&a,&b); //地址传递可以改变实参
cout << "a=" << a << endl;
cout << "b=" << b << endl;
system("pause");
return 0;
}