c语言用指针方法输入3个数a,b,c,按大小顺序输出,输出结果只能输出最小的那个其他两个有错求修改#include "stdio.h"#include "conio.h"main(){int n1,n2,n3;int *pointer1,*pointer2,*pointer3;printf("please input 3 number:n

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/28 22:05:24
c语言用指针方法输入3个数a,b,c,按大小顺序输出,输出结果只能输出最小的那个其他两个有错求修改#include
xSj@R#қo_YVjA^$>B&' mpzgk/:Zi;ZjgϞ9S$e+1lziE^1ҭS#]*BӦ't؍>L3ZL]OiPgQЭz?}n_/YojjKW|Xȗ5`_9uBȒ:LCQ .+LVmӳ%/nUl7W(kpBp8Q8RyYMeb`?"( p2H)l-!: b"]QpuUD.ΪK4;4cߣwi"yfK^j'Y>2J'ؾUSųD~ OI/~F)(P#?ߙ\!z2kҲwCގP0ڞm^gjIeLӝw^6XIk 6V~;\#&. 

c语言用指针方法输入3个数a,b,c,按大小顺序输出,输出结果只能输出最小的那个其他两个有错求修改#include "stdio.h"#include "conio.h"main(){int n1,n2,n3;int *pointer1,*pointer2,*pointer3;printf("please input 3 number:n
c语言用指针方法输入3个数a,b,c,按大小顺序输出,输出结果只能输出最小的那个其他两个有错求修改
#include "stdio.h"
#include "conio.h"
main()
{
int n1,n2,n3;
int *pointer1,*pointer2,*pointer3;
printf("please input 3 number:n1,n2,n3:");
scanf("%d,%d,%d",&n1,&n2,&n3);
pointer1=&n1;
pointer2=&n2;
pointer3=&n3;
if(n1>n2) swap(pointer1,pointer2);
if(n1>n3) swap(pointer1,pointer3);
if(n2>n3) swap(pointer2,pointer3);
printf("the sorted numbers are:%d,%d,%d\n",n1,n2,n3);
getch();
}
swap(p1,p2)
int *p1,*p2;
{
int p;
p=*p1;*p1=*p2;*p2=p;
}

c语言用指针方法输入3个数a,b,c,按大小顺序输出,输出结果只能输出最小的那个其他两个有错求修改#include "stdio.h"#include "conio.h"main(){int n1,n2,n3;int *pointer1,*pointer2,*pointer3;printf("please input 3 number:n
#include "stdio.h"
#include "conio.h"
swap(int *p1,int *p2) /*放在前面,不然要声明*/
{ /*你原来定义的int *p1,*p2;放在函数形参里面*/
int p;
p=*p1;*p1=*p2;*p2=p;
}
main()
{
int n1,n2,n3;
int *pointer1,*pointer2,*pointer3;
printf("please input 3 number:n1,n2,n3:");
scanf("%d,%d,%d",&n1,&n2,&n3);
pointer1=&n1;
pointer2=&n2;
pointer3=&n3;
if(n1>n2) swap(pointer1,pointer2);
if(n1>n3) swap(pointer1,pointer3);
if(n2>n3) swap(pointer2,pointer3);
printf("the sorted numbers are:%d,%d,%d\n",n1,n2,n3);
getch();
}