#include<stdio.h> #include<stdlib.h> #include<string.h> main() { char s[255]; char name[][255]={"aaa","bbb","ccc","ddd"}; int i,j,t,age[50]={30,23,15,32}; for(i=0;i<3;i++) for(j=i+1;j<4;j++) if(age[i]>age[j]) { t=age[i]; age[i]=age[j]; age[j]=t; strcpy(s,name[i]); strcpy(name[i],name[j]); strcpy(name[j],s); } printf("按年龄从小到大排序为: "); for(i=0;i<4;i++) printf("%s %d ",name[i],age[i]); system("PAUSE"); }