C语言:对输入两个整数按大小顺序输出
本帖最后由 划句顾 于 2021-6-1 23:50 编辑/*************************************************************
@author: LaoGu
@time: 2021/6/1
@fuction:对输入两个整数按大小顺序输出
*************************************************************/
#include<stdio.h>
int main()
{
void change(int *pa,int *pb);
int x,y,*p1,*p2;
printf("请输入x,y的值:");
scanf("%d %d",&x,&y);
printf("x = %d,\ty = %d\t\n",x,y);
p1 = &x;
p2 = &y;
change(p1,p2);
printf("p1 = %d,\tp2 = %d\t\n",*p1,*p2);
printf("x = %d,\ty = %d\t\n",x,y);
return 0;
}
void change(int *pa,int *pb)
{
int t;
t = *pa;
*pa = *pb;
*pb = t;
}
三目运算符不好吗 没想那么多{:10_279:}
页:
[1]