# include
int main()
{
int a=100,b=10;
int *pointer_1,*pointer_2;
pointer_1=&a;
pointer_2=&b;
printf("a=%d\tb=%d\n",a,b);
printf("*pointer_1=%d\t*pointer_2=%d\n",a,b);
return 0;
}
# include
int main()
{
int a,b,*p1,*p2,*p;
printf("please enter two integer number:");
scanf("%d%d",&a,&b);
p1=&a;
p2=&b;
if(a<b)
p=p1;p1=p2;p2=p;
printf("a=%d\tb=%d\n",a,b);
printf("max=%d,min=%d\n",*p1,*p2);
return 0;
}
# include
int main()
{
int swap(int *x,int *y);
int a,b,*p1,*p2;
printf("please enter two integer number:");
scanf("%d%d",&a,&b);
p1=&a;
p2=&b;
if(a<b)
swap(p1,p2);
printf("max=%d,min=%d\n",*p1,*p2);
return 0;
}
int swap(int *x,int *y)
{
int z;
z=*x;
*x=*y;
*y=z;
return (z);
}
# include
int main()
{
void swap(int *x,int *y);
int a,b;
int *p1,*p2;
printf("please enter two integer number:");
scanf("%d%d",&a,&b);
p1=&a;
p2=&b;
if(a<b)
swap(p1,p2);
printf("max=%d,min=%d\n",*p1,*p2);
return 0;
}
void swap(int *x,int *y)
{
int *z;
z=x;
x=y;
y=z;
}
# include
int main()
{
void swap(int *x,int *y);
int a,b,c;
int *p1,*p2,*p3;
printf("please enter three integer number:");
scanf("%d%d%d",&a,&b,&c);
p1=&a;
p2=&b;
p3=&c;
if(a<b)
swap(p1,p2);
if(a<c)
swap(p1,p3);
if(b<c)
swap(p2,p3);
printf("the order is:%d,%d,%d\n",*p1,*p2,*p3);
return 0;
}
void swap(int *x,int *y)
{
int z;
z=*x;
*x=*y;
*y=z;
}
运行结果如下:
# include
int main()
{
int a[10];
int *p,i;
printf("please enter 10 integer number:");
for(i=0;i<10;i++)
scanf("%d",&a[i]);
for(p=a;p<(a+10);p++)
printf("%d ",*p);
return 0;
}
# include
int main()
{
int a[10];
int *p=a,i;
printf("please enter 10 integer number:");
for(i=0;i<10;i++)
scanf("%d",p++);
p=a;
for(i=0;i<10;i++,p++)
printf("%d ",*p);
return 0;
}
运行结果如下:
# include
int main()
{
void inv(int *x,int n);
int a[10]={3,7,9,11,0,6,7,5,4,2};
int i;
printf("the original array:\n");
for(i=0;i<10;i++)
printf("%d ",a[i]);
printf("\n");
inv(a,10);
printf("the array has been inverted :\n");
for(i=0;i<10;i++)
printf("%d ",a[i]);
return 0;
}
void inv(int *x,int n)
{
int *p,temp,*i,*j,m=(n-1)/2;
i=x;j=x+n-1;p=x+m;
for(i=x;i<=p;i++,j--)
{ temp=*i;*i=*j;*j=temp;}
}
# include
int main()
{
void inv(int *x,int n);
int arr[10]={3,7,9,11,0,6,7,5,4,2};
int i,*p=arr;
printf("the original array:\n");
for(i=0;i<10;i++)
printf("%d ",*p++);
printf("\n");
p=arr;
inv(p,10);
printf("the array has been inverted :\n");
for(p=arr;p<(arr+10);p++)
printf("%d ",*p);
return 0;
}
void inv(int *x,int n)
{
int *p,temp,*i,*j,m=(n-1)/2;
i=x;j=x+n-1;p=x+m;
for(i=x;i<=p;i++,j--)
{ temp=*i;*i=*j;*j=temp;}
}
# include
int main()
{
void inv(int x[],int n);
int arr[10];
int i,*p;
p=arr;
printf("please enter 10 integer number:\n");
for(i=0;i<10;i++)
scanf("%d",&arr[i]);
p=arr;
inv(p,10);
for(p=arr;p<(arr+10);p++)
{ printf("%d ",*p);
}
return 0;
}
void inv(int x[],int n)
{
int i,j,t,k;
for(i=0;i<n-1;i++)
{
k=i;
for(j=i+1;j<n;j++)
if(x[j]>x[k])
k=j;
if(k!=i)
{t=x[i];x[i]=x[k];x[k]=t;}
}
}