该楼层疑似违规已被系统折叠隐藏此楼查看此楼
#include
#include
structstud{char*pp;intsum;structstud*next;};
structstud*creat1(intn)
{structstud*head,*newer,*p1,*p2;intt=0,k=0;char*pp1;
printf("输入字符串:");
newer=(structstud*)malloc(sizeof(structstud));
newer->pp=(char*)malloc(sizeof(char)*15);
gets(newer->pp);pp1=newer->pp;
while(*pp1)k+=*pp1++;newer->sum=k;
head=p1=p2=0;
while(t
{t++;
if(head==0){head=newer;newer->next=0;p1=head;}
else{while(p1->sum>newer->sum&&p1->next!=0)
{p2=p1;p1=p1->next;}
if(p1->sumsum)
if(head==p1)
{newer->next=p1;newer->next=head;head=newer;}
else{p2->next=newer;newer->next=p1;}
else
{p1->next=newer;newer->next=0;}p1=head;
newer=(structstud*)malloc(sizeof(structstud));
newer->pp=(char*)malloc(sizeof(char)*15);
gets(newer->pp);pp1=newer->pp;k=0;
while(*pp1)k+=*pp1++;newer->sum=k;}
newer->next=0;
}
return(head);
}
voidprint(structstud*head)
{while(head!=0){puts(head->pp);printf("\n");head=head->next;}}
main()
{structstud*p;intx;
printf("输入字符串的数量:\n");
scanf("%d",&x);
p=creat1(x);printf("降序排列字符串:\n");print(p);
system("PAUSE");
}
请教下各位指点迷津...看到链表这里还是有些晕
排序标准字符串各字符的asc2码值和