Êý¾Ý½á¹¹ºÍË㷨ʵÑéÖ¸µ¼Êé ÏÂÔØ±¾ÎÄ

WORD¸ñʽ¿É±à¼­ p=p->next; }

return 0; }

main()

{ SLIST *head; int k; char ch; char a[N]={'m','p','g','a','w','x','r','d'}; head=creatlist(a); outlist(head);

printf(\ scanf(\ k=fun(head,ch);

if (k==0) printf(\

else printf(\}

SLIST *creatlist(char *a) {

int i;

SLIST *tou,*p;

tou=(SLIST*)malloc(sizeof(SLIST)); //´´½¨²¢³õʼ»¯Í·½áµã tou->data=N; tou->next=NULL;

for(i=0;i

p=(SLIST*)malloc(sizeof(SLIST)); p->data=a[i];

p->next=tou->next; tou->next=p; }

return tou; }

void outlist(SLIST *h) { SLIST *p; p=h->next;

if (p==NULL) printf(\ else

{ printf(\ do

{ printf(\ while(p!=NULL); printf(\ } }

רҵ֪ʶ·ÖÏí

WORD¸ñʽ¿É±à¼­

3¡¢//ȥż²Ù×÷,Á´±íÖи÷½Úµã°´Êý¾ÝÓòµÝÔöÓÐÐòÁ´½Ó£¬º¯ÊýfunµÄ¹¦ÄÜÊÇ£¬É¾³ýÁ´±íÖÐÊý¾ÝÓòÖµÏàͬµÄ½Úµã£¬Ê¹Ö®Ö»±£ÁôÒ»¸ö

#include #include #define N 8 typedef struct list { int data;

struct list *next; } SLIST;

void fun( SLIST *h) {

SLIST *p,*shanchu; //ÓÃÓÚ±éÀúµÄÖ¸Õëp,ÓÃÓÚɾ³ýµÄÖ¸Õëshanchu p=h->next; /pΪÊÙÔª½Úµã while(p->next!=NULL) //ÖÕÖ¹Ìõ¼þ {

if(p->data==p->next->data) //ÅжÏÊÇ·ñÓÐÖØ¸´Ô­ËØ {

shanchu=p->next;

p->next=shanchu->next; free(shanchu); } else

p=p->next; } }

SLIST *creatlist(int *a)

{ SLIST *h,*p,*q; int i;

h=p=(SLIST *)malloc(sizeof(SLIST)); for(i=0; i

{ q=(SLIST *)malloc(sizeof(SLIST)); q->data=a[i]; p->next=q; p=q; }

p->next=0; return h;

רҵ֪ʶ·ÖÏí

WORD¸ñʽ¿É±à¼­ }

void outlist(SLIST *h) { SLIST *p; p=h->next;

if (p==NULL) printf(\ else

{ printf(\

do { printf(\ printf(\ } }

main( )

{ SLIST *head; int a[N]={1,2,2,3,4,4,4,5}; head=creatlist(a);

printf(\ fun(head);

printf(\}

4¡¢//ÔÚmainº¯ÊýÖжà´Îµ÷ÓÃfunº¯Êý£¬Ã¿µ÷ÓÃÒ»´Îfunº¯Êý£¬Êä³öÁ´±íβ²¿½ÚµãÖеÄÊý¾Ý£¬²¢ÊͷŸýڵ㣬ʹµÃÁ´±íËõ¶Ì¡£

#include #include #define N 8 typedef struct list { int data;

struct list *next; } SLIST;

void fun( SLIST *p) {

SLIST *bianli,*shanchu; //±éÀú£¬É¾³ý bianli=p; while(bianli->next->next!=NULL) {

bianli=bianli->next;

}

printf(\ //Êä³ö

רҵ֪ʶ·ÖÏí

WORD¸ñʽ¿É±à¼­ shanchu=bianli->next; //ÊÍ·Å free(shanchu); bianli->next=NULL; }

SLIST *creatlist(int *a)

{ SLIST *h,*p,*q; int i;

h=p=(SLIST *)malloc(sizeof(SLIST)); for(i=0; i

{ q=(SLIST *)malloc(sizeof(SLIST)); q->data=a[i]; p->next=q; p=q; }

p->next=0; return h; }

void outlist(SLIST *h) { SLIST *p; p=h->next;

if (p==NULL) printf(\ else

{ printf(\

do { printf(\ printf(\ } }

main()

{ SLIST *head;

int a[N]={11,12,15,18,19,22,25,29}; head=creatlist(a);

printf(\ printf(\ while (head->next != NULL){ fun(head);

printf(\

printf(\ } }

רҵ֪ʶ·ÖÏí

WORD¸ñʽ¿É±à¼­

5¡¢ÊµÏÖԼɪ·ò»·º¯Êý£¨Ñ¡×ö£© #include #include typedef struct list { int data;

struct list *next; } SLIST;

SLIST *creatlist(int m) {

int i;

SLIST *tou,*p,*wei; //Í·Ö¸Õë Éú³É½ÚµãÖ¸Õë βָÕë tou=(SLIST*)malloc(sizeof(SLIST)); //Í·½Úµã wei=tou;

רҵ֪ʶ·ÖÏí