#include<reg52.h>
#include<stdio.h>
#define uchar unsigned char
#define uint unsigned int
void init_uart() //串口初始化
{
SCON = 0x40;
PCON = 0;
REN = 1;
TMOD = 0x20;
TH1 = 0xfd;
TL1 = 0xfd;
TI = 1;
TR1 = 1;
}
void swop(uint *p1,uint *p2)
{
uint temp;
temp = *p1;
*p1 = *p2;
*p2 = temp;
}
void main()
{
uint x,y;
uint *p_x,*p_y;
init_uart();
p_x = &x;
p_y = &y;
while(1)
{
printf("please input two number\n");
scanf("&d&d",&x,&y);
if(*p_x < *p_y)
swop(p_x,p_y);
printf("seriation %d %d\n",*p_x,*p_y);
}
}
如上,代码是进行排序输出的。可是,发现输入的两个数并没有排序,而是仅仅按照我的输入顺序排序的,请教下坛友,我的代码哪有错误呢?