作业帮 > 综合 > 作业

对两个整数按大小顺序输出,用函数处理,且用指针类型的数据作函数参数 帮忙看看哪儿错了?

来源:学生作业帮 编辑:拍题作业网作业帮 分类:综合作业 时间:2024/04/29 01:26:35
对两个整数按大小顺序输出,用函数处理,且用指针类型的数据作函数参数 帮忙看看哪儿错了?
对两个整数按大小顺序输出,用函数处理,且用指针类型的数据作函数参数
程序如下 
#include <stdio.h>
void main ()
{
    void swapped (int *p1,int*p2);
 int a,b;
 int*pointer_1,*pointer_2;
 printf("Please input a & b:\n");
 scanf("%d,%d",&a,&b);
 pointer_1=&a;
 pointer_2=&b;
 if(a<b)
  swapped(pointer_1,pointer_2);
 printf("max =%d,min=%d\n",a,b);
}
void swapped (int *p1,int *p2)
{
 int t;
 t=*p1;
 *p1=*p2;
 *p2=t;
}
结果却是

请帮忙看看哪儿出错了?
2种修改方法
将scanf("%d,%d",&a,&b);改为scanf("%d%d",&a,&b);//去掉%d之间的逗号
在输入数据时,用英文的逗号分隔,如输入7,9而不是7 9
任意一种方法都可以