12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485#include using namespace std; struct node { int data; node *next; }; node *createlink(int n){ node *head = new node; int t; node *p; node *q; p=q=head; while(n--) { cin >> t; q= new node; q->data=t; p->next=q; p=q; } p->next=NULL; return head;} node *delnode(node *head, int m) { int t=0; int i; int index; while(m--) { cin >> index; index=index-t; t=t 1; node *p=head; node *q=p->next; i=0; while(q) { i ; if(i == index) { p->next=q->next; delete q; q=p->next; break; } else { p=p->next; q=q->next; } } } return head;} void outlink(node *head){ node *p=head->next; while(p) { cout data next; } cout > m; delnode(head,m); outlink(head); system("pause"); return 0;}
这是c ,需要改成c语言吗?
太长了,写不下。
你去附件下载吧 。CLink。zip大小:32。
68K | 所需财富值:5 已经过百度安全检测,放心下载点击下载下载量:0
你在手机上看不到?
你在手机上看不到我上传的附件吗?
稍等,我在手机上发给你
#include
#include
#include
typedef struct node {
int data;
struct node *next;
}node;
node *createlink(int n)
{
node *head =(node*)malloc(sizeof(node));
int t;
node *p;
node *q;
p=q=head;
while(n--)
{
scanf("%d",&t);
q= (node*)malloc(sizeof(node));
q->data=t;
p->next=q;
p=q;
}
p->next=NULL;
return head;
}
node *delnode(node *head, int m)
{
int t=0;
int i;
int index;
while(m--)
{
scanf("%d",&index);
index=index-t;
t=t 1;
node *p=head;
node *q=p->next;
i=0;
while(q)
{
i ;
if(i == index)
{
p->next=q->next;
free(q);
q=p->next;
break;
}
else
{
p=p->next;
q=q->next;
}
}
}
return head;
}
void outlink(node *head)
{
node *p=head->next;
while(p)
{
printf("%d ",p->data);
p=p->next;
}
printf("
");
}
int main()
{
node *head;
int n,m;
scanf("%d",&n);
head=createlink(n);
scanf("%d",&m);
delnode(head,m);
outlink(head);
system("pause");
return 0;
}。
全部