解题思路: 注意事项: 参考代码: #include<stdio.h> #include<stdlib.h> int num = 0; typedef struct stu { int num; int score; int flag; struct stu *next; }Node; Node head1, head2, *Phead1, *Phead2; void init() { Phead1 = &head1; Phead2 = &head2; Phead1->next = Phead2->next = NULL; } void show(Node *head, int n) { Node *p; printf("%d\n", n - num); p = head->next; while (p) { if (p->flag) printf("%d %d\n", p->num, p->score); p = p->next; } } Node *creatNode(Node *head, int num, int score) { Node *node = (Node *)malloc(sizeof(Node)); node->num = num; node->score = score; node->flag = 1; node->next = NULL; Node *p = head; while (p->next) { p = p->next; } p->next = node; return head; } void search(Node *head1, Node *head2) { Node *p1, *p2, *temp; p1 = head1->next; p2 = head2->next; int i = 0; while (p1) { p2 = head2; while (p2) { if (p1->num == p2->num) { p1->flag = 0; num++; } p2 = p2->next; } p1 = p1->next; } } int main() { int n, m, i, j, k, num, score; init(); scanf("%d %d", &n, &m); for (i = 0; i < n; i++) { scanf("%d %d", &num, &score); Phead1 = creatNode(Phead1, num, score); } for (i = 0; i < m; i++) { scanf("%d %d", &num, &score); Phead2 = creatNode(Phead2, num, score); } search(Phead1, Phead2); show(Phead1, n); return 0; }
0.0分
0 人评分
大神老白 (C语言代码)浏览:690 |
WU-字符串比较 (C++代码)浏览:824 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:645 |
循环入门练习6 (C语言代码)浏览:1058 |
杨辉三角 (C语言代码)浏览:504 |
C语言程序设计教程(第三版)课后习题9.4 (C语言代码)浏览:724 |
简单的a+b (C语言代码)浏览:497 |
小O的数字 (C++代码)浏览:806 |
2004年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:627 |
P1002 (C语言代码)浏览:1028 |