主题:C语言模块化没有执行
#include "stdio.h"
#include "stdlib.h"
#define AA sizeof(struct std)
typedef struct std
{ char data;
struct std *next;
}dd;
dd *list()
{ dd *h,*s,*r;
s=r=(dd *)malloc(AA);
printf("inter S :\n");
scanf("%c",&s->data);
s->next=NULL;
h=s;
while(s->data!='a')
{ r->next=s;
r=s;
s=(dd *)malloc(AA);
printf("inter :\n");
scanf(" %c",&s->data);/* c的前面加一个小的空格,来实现 */
}
r->next=NULL;
return h;
}
print(dd *head)
{ dd *p;
p=head;
if(head!=NULL)
do
{ printf("%3c",p->data);
p=p->next;
}while(p!=NULL);
}
dd *search(dd *head)
{ dd *p,*q;
p=head;
if(head!=NULL)
while(p->next!=NULL)
{ p=p->next;
}
if(p->next==NULL)
{q=p;
}
return q;
}
dd *add(dd *head,dd *head2)
{ dd *p,*q,*c,*d;
p=head;
q=head2;
if(head!=NULL&&head2!=NULL)
{ c=search(head);
d=search(head2);
}
c->next=q->next;
d->next=NULL;
return p;
}
dd *ads(dd *h1,dd *h2)
{ dd *p,*q,*f,*w,*r;
char x;
printf("\ninter the zi fu you have cong :\n");
scanf("%c",&x);
p=h1;
q=h2;
w=search(q);
r=search(p);
while(p->next->data!='x'&&p->next!=NULL)
{ p=p->next;
}
if(p->next->data=='x')
{ f=p;
f->next=q->next;
w->next=p->next;
r->next=NULL;
}
else
{ printf(" \n not found :\n");
exit (0);
}
return h1;
}
main()
{ dd *p,*q,*w;
printf("A\n");
p=list();
print(p);
printf("B\n");
q=list();
print(q);
printf("\n KAI shi :\n");
w=ads(p,q);
system("pause");
print(w);
getch();
}
他这个,ads没有执行,而且吧,就是说执行到ads这里就自动退出了。
这个函数的 作用是在一个链表里的某个节点里去插入另外一个链表,采用修改链表2 的执行域的方法,,,,请救 啊,,,
#include "stdlib.h"
#define AA sizeof(struct std)
typedef struct std
{ char data;
struct std *next;
}dd;
dd *list()
{ dd *h,*s,*r;
s=r=(dd *)malloc(AA);
printf("inter S :\n");
scanf("%c",&s->data);
s->next=NULL;
h=s;
while(s->data!='a')
{ r->next=s;
r=s;
s=(dd *)malloc(AA);
printf("inter :\n");
scanf(" %c",&s->data);/* c的前面加一个小的空格,来实现 */
}
r->next=NULL;
return h;
}
print(dd *head)
{ dd *p;
p=head;
if(head!=NULL)
do
{ printf("%3c",p->data);
p=p->next;
}while(p!=NULL);
}
dd *search(dd *head)
{ dd *p,*q;
p=head;
if(head!=NULL)
while(p->next!=NULL)
{ p=p->next;
}
if(p->next==NULL)
{q=p;
}
return q;
}
dd *add(dd *head,dd *head2)
{ dd *p,*q,*c,*d;
p=head;
q=head2;
if(head!=NULL&&head2!=NULL)
{ c=search(head);
d=search(head2);
}
c->next=q->next;
d->next=NULL;
return p;
}
dd *ads(dd *h1,dd *h2)
{ dd *p,*q,*f,*w,*r;
char x;
printf("\ninter the zi fu you have cong :\n");
scanf("%c",&x);
p=h1;
q=h2;
w=search(q);
r=search(p);
while(p->next->data!='x'&&p->next!=NULL)
{ p=p->next;
}
if(p->next->data=='x')
{ f=p;
f->next=q->next;
w->next=p->next;
r->next=NULL;
}
else
{ printf(" \n not found :\n");
exit (0);
}
return h1;
}
main()
{ dd *p,*q,*w;
printf("A\n");
p=list();
print(p);
printf("B\n");
q=list();
print(q);
printf("\n KAI shi :\n");
w=ads(p,q);
system("pause");
print(w);
getch();
}
他这个,ads没有执行,而且吧,就是说执行到ads这里就自动退出了。
这个函数的 作用是在一个链表里的某个节点里去插入另外一个链表,采用修改链表2 的执行域的方法,,,,请救 啊,,,