#include <stdio.h>
void swap(int *a, int *b, int *c);
int main(void)
{
int a, b, c;
printf("Enter three numders: ");
scanf("%d", &a, &b, &c);
swap(&a, &b, &c);
printf("The numders reordered: %d %d %d\n", a, b, c);
return 0;
}
void swap(int *a, int *b, int *c)
{
int temp;
if(*a > *b && *a > *c)
{
*a = *a;
if(*b > *c)
{
*b = *b;
*c = *c;
}
else
{
temp = *b;
*b = *c;
*c = temp;
}
}
else if(*b > *a && *b > *c)
{
temp = *a;
*a = *b;
if(*a > *c)
{
*b = temp;
*c = *c;
}
else
{
*b = *c
*c = temp;
}
}
else
{
temp = *a;
*a = *c;
if(*a > *b)
{
*c = *b;
*b = temp;
}
else
{
*b = *c;
*c = temp;
}
}
return;
}
答案 0 :(得分:2)
您在第44行忘了;
else
{
*b = *c //<<<<<
*c = temp;
}
在预处理阶段,所有换行都将被删除,编译器会尝试理解这个表达式:
*b = *c*c=temp