c语言指针三个整数比较大小按顺序输出~自己写了个不知道哪错了!#includevoid main(){int *i ,*j ,*k ,*p ,a ,b ,c;scanf("%d ,%d ,%d" ,&a ,&b ,&c);*i = &a; *j = &b; *k = &c;if(a > b){*p = a;a = b;b = *p;}if(a > c){*p = a;a = c;c =
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/26 10:31:51
c语言指针三个整数比较大小按顺序输出~自己写了个不知道哪错了!#includevoid main(){int *i ,*j ,*k ,*p ,a ,b ,c;scanf("%d ,%d ,%d" ,&a ,&b ,&c);*i = &a; *j = &b; *k = &c;if(a > b){*p = a;a = b;b = *p;}if(a > c){*p = a;a = c;c =
c语言指针三个整数比较大小按顺序输出~自己写了个不知道哪错了!
#include
void main()
{
int *i ,*j ,*k ,*p ,a ,b ,c;
scanf("%d ,%d ,%d" ,&a ,&b ,&c);
*i = &a; *j = &b; *k = &c;
if(a > b)
{
*p = a;a = b;b = *p;
}
if(a > c)
{
*p = a;a = c;c = *p;
}
if(b > c)
{
*p = b;b = c;c = *p;
}
printf("%d ,%d ,%d\n" ,*i ,*j ,*k);
}
c语言指针三个整数比较大小按顺序输出~自己写了个不知道哪错了!#includevoid main(){int *i ,*j ,*k ,*p ,a ,b ,c;scanf("%d ,%d ,%d" ,&a ,&b ,&c);*i = &a; *j = &b; *k = &c;if(a > b){*p = a;a = b;b = *p;}if(a > c){*p = a;a = c;c =
因为你的p没有赋初值所以会出错,帮你修改一下:
#include
void main()
{
int *i , *j , *k , temp, a , b , c;
scanf("%d , %d , %d" , &a , &b ,&c);
i = &a; j = &b; k = &c;
if(a > b)
{
temp= a;a = b;b = temp;
}
if(a > c)
{
temp = a;a = c;c = temp;
}
if(b > c)
{
temp = b;b = c;c = temp;
}
printf("%d , %d , %d\n" , *i , *j , *k);
}