数据结构与算法的问题,使用C语言,如何将其补充完整

[](

#include <stdlib.h>
#include <stdio.h>

//SwapInt,交换x和y指向的内存地址的值 
bool SwapInt(int* x, int* y);

//ThreeIntSort,输入的整数存放在x1,x2,x3指向的内存地址 
//输出:要求x1,x2,x3地址中存放的整数是按照从小到大的顺序排好的 
bool ThreeIntSort(int* x1, int* x2, int* x3);

//FourIntSort,输入的整数存放在x1,x2,x3,x4指向的内存地址 
//输出:要求x1,x2,x3,x4地址中存放的整数是按照从小到大的顺序排好的 
bool FourIntSort(int* x1, int* x2, int* x3, int* x4);

//ThreeIntSort,输入的整数存放在x1,x2,x3,x4,x5指向的内存地址 
//输出:要求x1,x2,x3,x4,x5地址中存放的整数是按照从小到大的顺序排好的 
bool FiveIntSort(int* x1, int* x2, int* x3, int* x4, int* x5);

int main()
{
    int a,b,c,d,e;
    
    //从命令行读入5个整数,放在a b c d e五个变量里
    //补充实现代码
     
    if( ThreeIntSort( /*补充实现代码*/))
        printf("\n 前三个整数排序结果:%d %d %d\n", a, b, c, d);
        
    if( FourIntSort(/*补充实现代码*/))    
        printf("\n 前四个整数排序结果:%d %d %d %d\n", a, b, c, d);
    
    if( FiveIntSort(/*补充实现代码*/))    
        printf("\n 前五个整数排序结果:%d %d %d %d %d\n", a, b, c, d, e);
        
    return 0;
)


```**_
bool ThreeIntSort(int* x1, int* x2, int* x3)
{
    //补充实现代码 
}
bool FourIntSort(int* x1, int* x2, int* x3, int* x4)
{
    //补充实现代码 
}
bool FiveIntSort(int* x1, int* x2, int* x3, int* x4, int* x5)
{
    //补充实现代码 
}

bool SwapInt(int* x, int* y)
{
    //补充实现代码 
}


```)
要求:
-1) 阅读 job1.cpp 代码,补充 job1.cpp 中缺少的代码实现程序目标
a) 补充读入 5 个整数的代码;
b) 补充三个排序函数的代码;
c) 补充 main 函数中调用三个排序函数的代码;
d) 补充 SwapInt 函数的代码;
2) 从命令行读入的 5 个整数存放在 5 个变量中,不能存放在数组中;
3) 在 ThreeIntSort、FourIntSort、FiveIntSort 的实现中,不能把数值放在数
组中进行排序,不能使用 C/C++标准库;
4) 不能使用全局变量;
5) SwapInt 函数可以实现后被三个排序函数使用,也可以不使用。
#include <stdlib.h>
#include <stdio.h>
 
//SwapInt,交换x和y指向的内存地址的值 
bool SwapInt(int* x, int* y);
 
//ThreeIntSort,输入的整数存放在x1,x2,x3指向的内存地址 
//输出:要求x1,x2,x3地址中存放的整数是按照从小到大的顺序排好的 
bool ThreeIntSort(int* x1, int* x2, int* x3);
 
//FourIntSort,输入的整数存放在x1,x2,x3,x4指向的内存地址 
//输出:要求x1,x2,x3,x4地址中存放的整数是按照从小到大的顺序排好的 
bool FourIntSort(int* x1, int* x2, int* x3, int* x4);
 
//ThreeIntSort,输入的整数存放在x1,x2,x3,x4,x5指向的内存地址 
//输出:要求x1,x2,x3,x4,x5地址中存放的整数是按照从小到大的顺序排好的 
bool FiveIntSort(int* x1, int* x2, int* x3, int* x4, int* x5);
 
int main()
{
    int a,b,c,d,e;
    
    //从命令行读入5个整数,放在a b c d e五个变量里
    scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
    //补充实现代码
     
    if( ThreeIntSort(&a,&b,&c))
        printf("\n 前三个整数排序结果:%d %d %d\n", a, b, c);
        
    if( FourIntSort(&a,&b,&c,&d))    
        printf("\n 前四个整数排序结果:%d %d %d %d\n", a, b, c, d);
    
    if( FiveIntSort(&a,&b,&c,&d,&e))    
        printf("\n 前五个整数排序结果:%d %d %d %d %d\n", a, b, c, d, e);

    return 0;
}
 

bool ThreeIntSort(int* x1, int* x2, int* x3)
{
    if(*x1 > *x2)
        SwapInt(x1,x2);
    if(*x1 > *x3)
        SwapInt(x1,x3);
    if(*x2 > *x3)
        SwapInt(x2,x3);
    return true;
}
bool FourIntSort(int* x1, int* x2, int* x3, int* x4)
{
    ThreeIntSort(x1,x2,x3);
    ThreeIntSort(x1,x2,x4);
    ThreeIntSort(x2,x3,x4);
    return true;
}
bool FiveIntSort(int* x1, int* x2, int* x3, int* x4, int* x5)
{
    FourIntSort(x1,x2,x3,x4);
    FourIntSort(x1,x2,x3,x5);
    FourIntSort(x1,x2,x4,x5);
    FourIntSort(x1,x3,x4,x5);
    FourIntSort(x2,x3,x4,x5);
    return true; 
}
 
bool SwapInt(int* x, int* y)
{
    int t;
    t = *x;
    *x = *y;
    *y = t;
    return true;
}

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632