结构体 字典序排序
1334
sdut
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
struct
{char name[21];int sorce;
}
a[10];
int main()
{char q[21];int w,i,j;for(i=0;i<10;i++){scanf("s",&a[i].name);}for(i=0;i<10;i++)scanf("%d ",&a[i].sorce);for(i=0;i<9;i++)for(j=i+1;j<10;j++)if(strcmp(a[i].name,a[j].name)>0){strcpy(q,a[i].name);strcpy(a[i].name,a[j].name);strcpy(a[j].name,q);w=a[i].sorce;a[i].sorce=a[j].sorce;a[j].sorce=w;}for(i=0;i<10;i++)printf("%s,%d\n",a[i].name,a[i].sorce);return 0;
}
谁能告诉我用指针该怎么做????
谢谢!!!!!!!!!!!!!!!