满意答案
xvercjdl3
2013.10.07
采纳率:47% 等级:10
已帮助:272人
#include
#include
int cmp(const void* a, const void* b)
{
return *(int*)a > *(int*)b;
}
int main()
{
int arr[5][5];
int tmp[5];
int ct = 0;
int i,j;
printf("input 25 numbers: \n");
for(i = 0; i
{
for(j = 0; j
{
printf("%d: ", ++ct);
scanf("%d", &arr[i][j]);
}
}
ct = 0;
printf("the array is: \n");
for(i = 0; i
{
for(j = 0; j
{
printf("\t%d", arr[i][j]);
if(j == 2)
tmp[ct++] = arr[i][j];
}
printf("\n");
}
ct = 0;
qsort(tmp, 5, sizeof(int), cmp);
printf("after the sort the second col, is: \n");
for(i = 0; i
{
for(j = 0; j
{
if(j == 2)
arr[i][j] = tmp[ct++];
printf("\t%d", arr[i][j]);
}
printf("\n");
}
printf("\n");
return 0;
}
00分享举报