#include
Int main ()
{
Int x [5]=,8,9,1,2 {4};
Char name [5] [80]={" zhang ", "hei", "haha", "asas", "qwe"};
Char copy [80].
int i=0;
int n;
Int Max;
/* for (I=0; i<5; I++) {
Printf (" input the name: ");
The scanf (" % s ", & amp; The name [I]);
Printf (" input the score: ");
The scanf (" % d ", & amp; X [I]);
} */
While (i<5) {
Max=I;
For (n=I; N<5; N++) {
If (x (Max) & gt; [n]) {x
Max=Max;
} else {
Max=n;
}
}
//printf (" % d ", Max);
N=x [I];
[I]=x x (Max);
X (Max)=n;
Strcpy (copy, name (Max));
Strcpy (name (Max), the name [I]);
Strcpy (name [I], copy);
i++;
}
For (n=0; N<5; N++) {
Printf (" % s % d \ n, "the name [n], [n] x);
}
return 0;
}
This code if their input is not sorted, but defined in advance can sort, beg you,
CodePudding user response:
I'm sorry, I wrong, you cycle, after I return to zero againCodePudding user response:
for(i=0; i<5; I++) {Printf (" input the name: ");
The scanf (" % s ", & amp; The name [I]);
Printf (" input the score: ");
The scanf (" % d ", & amp; X [I]);
}
I have been here 5, so the following loop into don't go, again can be set to 0
Increase I=0;
While (i<5) {
.
CodePudding user response:
The name [5] [80]The name [80] [5]
Who is really?
CodePudding user response: