下列给定程序中函数fun的功能是:用冒泡法对6个字符串进行升序排列。 请改正程序中的错误,使它能得出正确的结果。 注意:部分源程序在文件MODll.C中,不得增行或删行,也不得更改程序的结构! #include #include #

admin2016-06-23  15

问题 下列给定程序中函数fun的功能是:用冒泡法对6个字符串进行升序排列。
请改正程序中的错误,使它能得出正确的结果。
注意:部分源程序在文件MODll.C中,不得增行或删行,也不得更改程序的结构!
    #include
    #include
    #define MAXLINE 20
    fun(char*pstr[6])
    {  int i,j;
    char*P;
    for(i=0;i<5;i++){
    /**********found**********/
    for(j=i+1,j<6,j++)
    {
    if(strcmp(*(pstr+i),*(pstr+j))>0)
    {
    P=*(pstr+i);
    /**********found**********/
    *(pstr+i)=pstr+j;
    *(pstr+j)=P;
    }
    }
    }
    }
    main()
    {    int i:
    char*pstr[6],str[6][MAXLINE];
    for(i=0;i<6;i++)pstr=str
    prinff(“\nEnter 6 string(1 string at each line):\n”);
    for(i=0;i<6;i++)  scanf(“%s”,pstr);
    fun(pstr);
    prinff(“The strings after sorting:\n”);
    for(i=0;i<6;i++)prinff(“%s\n”,pstr);
    }

选项

答案(1)for(j=i+1;j<6;j++) (2)*(pslr+i)=*(pstr+j);

解析
转载请注明原文地址:https://kaotiyun.com/show/afID777K
0

相关试题推荐
最新回复(0)