本帖最后由 king、小白 于 2016-5-27 01:11 编辑
#include <stdio.h>
#include "string.h"
int main(int argc, const char * argv[]) {
char ch[10][100];
int num[10];
for (int i = 0; i < 10; i++) {
printf("qingshuruxingminghegonghao\n");
rewind(stdin);
scanf("%s%d",ch,&num);
}
for (int i = 0; i < 10; i++) {
for (int j =0; j<10; j++) {
int temp;
char na[100];
if (num[j] > num) {
temp = num[j];
num[j] = num;
num = temp;
strcpy(na,ch[j]);
strcpy(ch[j],ch);
strcpy(ch, na);
}
}
}
for (int i = 0; i < 10; i++) {
printf("%d,%s\n",num,ch);
}
return 0;
}
qingshuruxingminghegonghao qq 1 qingshuruxingminghegonghao ww 3 qingshuruxingminghegonghao ee 5 qingshuruxingminghegonghao rr 7 qingshuruxingminghegonghao tt 9 qingshuruxingminghegonghao yy 2 qingshuruxingminghegonghao uu 4 qingshuruxingminghegonghao ii 6 qingshuruxingminghegonghao oo 8 qingshuruxingminghegonghao pp 10 1,qq 2,yy 3,ww 4,uu 5,ee 6,ii 7,rr 8,oo 9,tt 10,pp Program ended with exit code: 0
|