| 
 | 
 
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册  
 
x
 
- struct myLink
 - {  
 -     int value;  //数据域  
 -     struct myLink *next;    //指针域  
 - };  
 - class Link
 - {  
 - private:  
 -     struct myLink *head;    //头指针  
 -     struct myLink *cur; //当前位置的指针  
 -     int length; //link的长度  
 
  void Link::sort() 
{ 
        if(length >1 ) 
        { 
                int count =1 ; 
                while(length!=count) 
                { 
                        int i= count ; 
                        struct myLink * temp = head; 
                        cur = head ; 
                        while(length !=i ) 
                        { 
                                if(cur->value > cur->next->value ) 
                                { 
                                        cur->value += cur->next->value; 
                                        cur->next->value = cur->value - cur->next->value; 
                                        cur->value -= cur->next->value;   
                                } 
                                cur = cur->next; 
                                i++ ; 
                        } 
                        temp = temp->next ;   这个地方一直想不明白,这句代码有必要存在吗? 
                        count++ ;    
                } 
        } 
} 
 
 
 
 |   
 
 
 
 |