Select the large valuo in two Formal parameter in aj function.then take the large valuo pass the value back to the two formal parameters.But program unable to run. the code as follows:
#include<stdio.h>
void aj(int *a,int *b){
if(*a>*b)
*b=*a;
else
*a=*b;
}
int main(void){
int *x;
int *y;
scanf("%d%d",x,y);
aj(x,y);
printf("%d %d",*x,*y);
return 0;
}
after search the cause.So that is it.I did not point to the object with pointer.So i declare an variable for the pointer. Let the pointer point the variable.After modification,the code as follows:
#include<stdio.h>
void aj(int *a,int *b){
if(*a>*b)
*b=*a;
else
*a=*b;
}
int main(void){
int x;
int y;
int *g;
int *h;
g=&x;
h=&y;
scanf("%d%d",g,h);
aj(g,h);
printf("%d %d",*g,*h);
return 0;
}