指针初体验

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>

int main(){
 //从小到大排列数字
 int a = 0;
 int b = 0;
 int c = 0;
 int t;
 int *d, *e, *f;
 printf("请输入三个数:");
 scanf("%d%d%d", &a, &b, &c);

 d = &a;
 e = &b;
 f = &c;
 
 if (a > b){
  t = *d;
  *d = *e;
  *e = t;
 }
 if (a > c){
  t = *d;
  *d = *f;
  *f = t;
 }
 if (b > c){
  t = *e;
  *e = *f;
  *f = t;
 }

 printf("%d <= %d <= %d\n", *d, *e, *f);
 printf("%d <= %d <= %d\n", a, b, c);
 system("pause");
 return 0;
}

posted @ 2020-04-04 20:32  听说在北郭  阅读(123)  评论(0)    收藏  举报