在main.cpp里输入程序如下:
#include <iostream> //使能cin(),cout();
#include <iomanip> //使能setbase(),setfill(),setw(),
//setprecision(),setiosflags()和resetiosflags();
using namespace std; //告诉编译器使用std标准程序库;
void Swap_Number(int *p1,int *p2); //声明函数Swap_Number();
int main()
{
int data1,data2; //声明int型变量data1和data2;
data1=1;data2=2;
cout<<"交换前\t"<<"data1 = "<<data1<<"\t"<<"cata2 = "<<data2<<endl;
Swap_Number(&data1,&data2);
cout<<"交换后\t"<<"data1 = "<<data1<<"\t"<<"cata2 = "<<data2<<endl;
return(0); //退出函数;
}
void Swap_Number(int *p1,int *p2)
{
int temp;
temp=*p1;
*p1=*p2;
*p2=temp;
}