发个C++ 指针的例子
//简单的指针程序#include<iostream>
using namespace std;
int main()
{
cout<<"这是一个通过指针指向来区别大小写的程序.";
void sp(int *p1,int *p2);
int a,b;
int *pointer1,*pointer2;
cout<<"请输入两个数:"<<endl;
cin>>a>>b;
pointer1=&a;
pointer2=&b;
cout<<"你输入的数是:"<<a<<" "<<b<<" "<<endl;
if(a<b)
sp(pointer1,pointer2);
cout<<a<<" "<<b<<" "<<endl;
cout<<*pointer1<<" "<<*pointer2<<endl;
return 0;
}
void sp(int *p1,int *p2)
{
int temp;
temp=*p1;
*p1=*p2;
*p2=temp;
}
页:
[1]