Home > Back-end >  Strives for the big help
Strives for the big help

Time:12-04

Subject requirements through input () function to achieve input several words (each length no more than 20 words, words does not exceed the maximum number of 10), encountered in the process of input words * * END ahead of an END to the input END (* * not behind as a sort of words), or the number to ten words is over, then calls the function paixu (), to the number of words in dictionary order sorting, finally calling function printArr sort () output after the words, the output between words separated by Spaces, no Spaces after the last word,
#include
#include
Int input (char ar2 [] [21]);
Void paixu (char ar2 [] [21], int n);
Void printArr (char ar2 [] [21], int n);
Int main (void)
{
Char arr [10] [21]={0};
Int n;
N=input (arr);
Paixu (arr, n);
PrintArr (arr, n);

return 0;
}
/* please fill in the answer here */

CodePudding user response:

His first writing, use the scanf % s or the fgets, either getchar () loop

CodePudding user response:

Int input (char ar2 [] [21])
{
int i=0;
While (i<10 & amp; & Ar2! END='* *')
{
Gets (ar2);
i++;
}
return i;
}

Void paixu (char ar2 [] [21], int n)
{
int i,j,t;
for(i=0; i{
For (j=I + 1; j{
If (ar2 [0] [m + 1] <=ar2 [j] [0])
{
T=ar2 [j] [0];
Ar2 [j] [0]=ar2 [j + 1] [0];
Ar2 [m + 1] [0]=t;
}

}
}

}


Void printArr (char ar2 [] [21], int n)
{
int i;
Char ch=' ';
for(i=0; i{
If (I==(n - 1))
{ch='\ n'; }
Printf (" % d % c ", ar2 [I] [21], ch);
}
Return ar2;
}
In the wrong
  • Related