鱼C论坛

 找回密码
 立即注册
查看: 2654|回复: 4

求助吖

[复制链接]
发表于 2020-4-25 11:57:08 | 显示全部楼层
  1. #include <stdio.h>
  2. void swap(int *p1,int *p2);
  3. int main()
  4. {
  5.   int a,b;
  6.   int *pointer_1,*pointer_2;
  7.   printf("please input a and b:");
  8.   scanf("%d %d",&a,&b);
  9.   pointer_1=&a;
  10.   pointer_2=&b;  
  11.   if (a<b)
  12.   {
  13.           swap(pointer_1,pointer_2);
  14.   }
  15.   printf("max=%d,min=%d\n",*pointer_1,*pointer_2);
  16.   return 0;
  17. }   
  18. void swap(int *p1,int *p2)
  19. {
  20.    int temp;
  21.    temp=*p1;     
  22.    *p1=*p2;
  23.    *p2=temp;
  24. }
复制代码

scanf有问题这样写就没问题了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-10-16 03:20

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表