| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 348 人关注过本帖, 1 人收藏
标题:链表排序 各位大大们看一下 指导下
只看楼主 加入收藏
狼族孤星
Rank: 1
等 级:新手上路
帖 子:11
专家分:3
注 册:2010-6-22
结帖率:50%
收藏(1)
 问题点数:0 回复次数:1 
链表排序 各位大大们看一下 指导下
struct adlist{
   char name[50];//名字
   char home[100];//家庭住址
   char workd[100];//工作地点
   char academy[50];//学院
   char profession[50];//专业
   char tele[20];//电话
   char phone[20];//座机
   char QQ[20];
   char Email[50];
   char job[50];
   struct adlist*next;        
   }adl;








 struct adlist* sort(struct adlist*head)//排序
{  //struct adlist*head;
   struct adlist*p,*p1,*p2;
   
   for(p=head->next;p->next!=NULL;p=p->next)
    {   
         if(strcmp(p->QQ,(p->next)->QQ)>0)                                 
             {   p1=p2=(struct adlist*) malloc(LEN);   
                  *p1=*p;  
                  while(p1->name[0]!='0')
                     {n=n+1;
                        if(n==1)   head=p1;                  
                        else  p2->next=p1;
                          p2=p1;
                         p1=(struct adlist*)malloc(LEN);                                                                              
                     }
              }
                                                                     
     }
    p2->next=NULL;
   
   printf("按QQ排序\n");
   //print(p2);
  return(head);  
   
    }      
搜索更多相关主题的帖子: 链表 指导 
2010-09-07 15:09
狼族孤星
Rank: 1
等 级:新手上路
帖 子:11
专家分:3
注 册:2010-6-22
收藏
得分:0 
struct adlist* sort(struct adlist*head)
{  
   struct adlist*p,*p1,*p2;
   struct adlist*temp;
   char str[100];
   p2=head;
   for(p=head->next;p!=NULL;p=p->next)
    { for(p1=head->next;p1->next!=NULL;p1=p1->next)
         { if(strcmp(p->QQ,p1->QQ)>0)                                 
             { *temp= *p;
              *p=*p1;
              *p1=*temp;                                                                                                               
             }
         }   
    }
    p2=head;
  //  print(p2);
    return(p2);
}      



这个帮忙看看哈
2010-09-07 15:27
快速回复:链表排序 各位大大们看一下 指导下
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011648 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved