#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct student{
int num;
int score;
struct student *next;
};
struct student *creat(int n){
struct student *head,*tail,*p;
int i;
head=(struct student*)malloc(n*sizeof(struct student*));
tail=head;
for(i=0;i<n;i++){
p=(struct student*)malloc(n*sizeof(struct student*));
scanf("%d %d",&p->num,&p->score);
tail->next=p;
tail=p;
}
tail->next=NULL;
return head;
}
struct student *DeleteCommon(struct student *a,struct student *b){
struct student *p1,*p2,*prep;
int judge;
for(prep=a,p1=a->next;p1 != NULL;p1=p1->next){
judge=1;
for(p2=b->next;p2 != NULL;p2=p2->next){
if(p1->num == p2->num){
prep->next=p1->next;//删除节点
judge=0;
break;
}
}
if(judge) prep=prep->next;
}
return a;
}
int print(struct student *a){
struct student *p=a;
while(p->next != NULL){
p=p->next;
printf("%d %d\n",p->num,p->score);
}
return 0;
}
int main()
{
struct student *a,*b,*p;
int n,m;
scanf("%d %d",&n,&m);
a=creat(n);
b=creat(m);
DeleteCommon(a,b);
int i=0;
for(p=a;p->next != NULL;p=p->next){
i++;
}
printf("%d\n",i);
print(a);
return 0;
}
0.0分
0 人评分
1908题解浏览:633 |
C语言程序设计教程(第三版)课后习题9.8 (C语言代码)浏览:664 |
1054题解浏览:460 |
生日日数 (C语言代码)浏览:1490 |
C语言程序设计教程(第三版)课后习题5.4 (C语言代码)浏览:455 |
逆反的01串 (C语言代码)浏览:1430 |
C语言程序设计教程(第三版)课后习题7.5 (C++代码)浏览:1379 |
C语言训练-自由落体问题 (C语言代码)浏览:607 |
Manchester-数字整除最原始易理解方法浏览:4459 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:303 |