编辑代码

#include <stdio.h>
#include <string.h>
int main () {
    int i,j;
    char str;
    struct days{
        char name[20];
        long tel;
    }days,stu[5]={{"hfaq",654},{"lll",4456},{"ewfio",853},{"oidp",231},{"bbb",45432}};
	/*printf("input information of students\n");
    for(i=0;i<5;i++){
        scanf("%s",&stu[i].name);
        scanf("%ld",&stu[i].tel);
    }*/
    printf("name\ttelephone\n");
    for(i=0;i<5;i++){
        printf("%s\t%ld\n",stu[i].name,stu[i].tel);
    }
    for(i=0;i<4;i++)
    for(j=i;j<5;j++){
        if(strcmp(stu[i].name,stu[j].name)>0){
            days=stu[i];
            stu[i]=stu[j];
            stu[j]=days;
        }
    }
    printf("\n");
    printf("name\ttelephone\n");
    for(i=0;i<5;i++){
        printf("%s\t%ld\n",stu[i].name,stu[i].tel);
    }
	return 0;
}