对两个整数按大小顺序输出,用函数处理,且用指针类型的数据作函数参数 帮忙看看哪儿错了?
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/10/04 15: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;
}
结果却是
请帮忙看看哪儿出错了?
对两个整数按大小顺序输出,用函数处理,且用指针类型的数据作函数参数
程序如下
#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
任意一种方法都可以
将scanf("%d,%d",&a,&b);改为scanf("%d%d",&a,&b);//去掉%d之间的逗号
在输入数据时,用英文的逗号分隔,如输入7,9而不是7 9
任意一种方法都可以
对两个整数按大小顺序输出,用函数处理,且用指针类型的数据作函数参数 帮忙看看哪儿错了?
用指针类型的数据作为函数参数,对输入的两个整数按大小顺序输出.
1) 输入3个整数,按由小到大的顺序输出.编译一个函数,用指针变量作为参数.
输入3个整数,按从小到大的顺序输出(用指针处理)
用C++语言,编写一个函数,它交换两个整数(交换他们的值),用int*作参数类型.
编写一个c程序,用指针的方法成功处理,输入3个整数,按由小到大的顺序输出
编一个函数sort,使10个整数按升序排列,在main函数中输入这10个数,并输出排好序的数,函数参数用指针实现
c语言指针三个整数比较大小按顺序输出~自己写了个不知道哪错了!
c语言用指针方法输入3个数a,b,c,按大小顺序输出,输出结果只能输出最小的那个其他两个有错求修改
C语言,返回3个整数中的最大值,要求用指针作为函数参数得到最大值,在主函数中输入输出数据
c语言:输入3个整数,按由小到大的顺序输出(要求用指针).
C语言:用指针编程:有一个数列,含有20个整数,编写函数,要求能够对从指定位置开始的n个数按相反顺序重