#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 人评分
点我有惊喜!你懂得!浏览:2071 |
C语言程序设计教程(第三版)课后习题7.2 (C语言代码)浏览:532 |
C语言训练-求具有abcd=(ab+cd)2性质的四位数 (C语言代码)浏览:562 |
矩阵乘法 (C++代码)浏览:1454 |
简单的a+b (C语言代码)浏览:524 |
C语言程序设计教程(第三版)课后习题6.4 (C语言代码)浏览:1029 |
C语言程序设计教程(第三版)课后习题6.9 (C语言代码)浏览:994 |
C语言训练-阶乘和数* (C语言代码)-------- 呆板写法浏览:1345 |
WU-陶陶摘苹果2 (C++代码)浏览:968 |
Cylinder (C语言描述+详细分析)浏览:3262 |