20¡¢ÔÚË«ÏòÁ´±íÖÐɾ³ýÖ¸¶¨ÔªËØ¡£ 1void del(List head, List node){ 2 List pre=new List(); 3 pre.next = head; 4 List cur = head; 5 while(cur && cur!=node){ 6 cur=cur.next; 7 pre=pre.next; 8 } 9 if(!cur) return; 10 List post = cur.next; 11 pre.next=cur.next; 12 post.last=cur.last; 13 return; 14} 21¡¢²»Öظ´µØÊä³öÉýÐòÊý×éÖеÄÔªËØ¡£ 1 void outputUnique( char [] str, int n) { 2 if (n <= 0 ) return ; 3 elseif(n == 1 ) putchar(str[ 0 ]); 4 else { 5 int i = 0 ,j = 1 ; 6 putchar(str[ 0 ]); 7 while (j < n) { 8 if (str[j] !== str[i]) { 9 putchar(str[j]); 10 i = j; 11 } 12 ++ j; 13 } 14 } 15 } 22¡¢ÃæÊÔ¹ý³ÌÖÐÎÒ»¹Óöµ½ÁËÏÂÃ漸Ì⣺ 1¡¢ÈçºÎɾ³ýÁ´±íµÄµ¹ÊýµÚmµÄÔªËØ£¿Îҵķ½·¨ÊÇÏÈÓÃpreÖ¸Õë´ÓÁ´±íÍ·¿ªÊ¼²½½øm£¬Ð½¨pst½ÚµãnextÖ¸ÕëÖ¸ÏòÍ·½Úµã£¬curÖ¸ÕëÖ¸ÏòÍ·½Úµã£¬È»ºópre£¬cur£¬postÈý¸öÖ¸ÕëÒ»Æð²½½ø£¬µ±preÖ¸ÏòÁ´±í½áβµÄʱºòcurÖ¸Ïòµ¹ÊýµÚm¸öÔªËØ£¬×îºóÀûÓÃpstÖ¸Õëɾ³ýcurÖ¸ÏòÔªËØ¡£ 2¡¢ÈçºÎÅжÏÒ»¸ö×Ö·û´®ÊǶԳƵģ¿Èça£¬aa£¬aba¡£ÉèÖÃͷβָÕëͬʱÏòÖмä±È½Ï¿¿ÆëÖ±ÖÁÏàÓö¡£ 3¡¢ÈçºÎÀûÓÃ2º¯ÊýÕÒ³öÒ»¸ö×Ö·û´®ÖеÄËùÓжԳÆ×Ó´®£¿ÒÔ×Ó´®Í·Ö¸ÕëºÍβָÕëΪѻ·±äÁ¿ÉèÖÃÁ½¸öǶÌ×µÄÑ»·ÒÔÕÒ³öËùÓÐ×Ó´®£¬¶Ôÿ¸ö×Ó´®Ó¦ÓÃ2º¯Êý¡£ |