#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 人评分
C语言程序设计教程(第三版)课后习题10.1 (C语言代码)浏览:1435 |
C二级辅导-计负均正 (C语言代码)浏览:508 |
矩阵转置 (C语言代码)浏览:1522 |
C语言程序设计教程(第三版)课后习题9.4 (Java代码)浏览:1416 |
最小公倍数 (C语言代码)浏览:862 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:896 |
C语言程序设计教程(第三版)课后习题6.4 (C语言代码)浏览:1028 |
【排队买票】 (C语言代码)浏览:899 |
WU-链表数据求和操作 (C++代码)浏览:1312 |
三角形 (C++代码)递归(存在大量重复计算,容易出现时间超限)浏览:774 |