SDUT—2057 模拟题
来源:互联网 发布:大数据分析软件 编辑:程序博客网 时间:2024/05/16 07:51
#include <cstdio>#include <cstring>#include <cstdlib>#include <iostream>#include <algorithm>using namespace std;struct N{ int data; char name[21]; N *next;};N *creat(){ N *p = (struct N *)malloc(sizeof(struct N)); p->next = NULL; return p;}void link(N *head,N *p){ N *q = head; for(;q->next != NULL && q->next->data >= p->data; q = q->next); p->next = q->next; q->next = p;}int del(N *head,char *name){ N *p = head; N *q = head->next; for(;q->next != NULL && strcmp(name,q->name) != 0;p = p->next,q = q->next); p->next = q->next; return q->data;}void change(N *head,N *p){ p->data += del(head,p->name); link(head,p);}void output_rank(N *head){ int sum,temp; printf("#1 :"); for(head = head->next,temp = head->data;head != NULL;) { if(temp == head->data) { printf(" %s",head->name); head = head->next; } else break; } if(head == NULL) return; printf("\n#2 :"); for(temp = head->data,sum = 1;head != NULL;) { if(temp == head->data) { printf(" %s",head->name); head = head->next; } else { sum++; if(sum <= 2) { temp = head->data; printf(" %s",head->name); head = head->next; } else break; } } if(head == NULL) return; printf("\n#3 :"); for(temp = head->data,sum = 1;head != NULL;) { if(temp == head->data) { printf(" %s",head->name); head = head->next; } else { sum++; if(sum <= 3) { temp = head->data; printf(" %s",head->name); head = head->next; } else break; } } printf("\n");}void output(N *head){ for(N *p = head->next; p != NULL; p = p->next) cout<<p->name<<' '<<p->data<<endl;}int main(){ int n; N *head = creat(); cin>>n; for(int i = 0;i < n; i++) { N *p = creat(); cin>>p->name>>p->data; link(head,p); } char order; while(cin>>order && order != 'O') { if(order == 'A') { N *p = creat(); cin>>p->name>>p->data; link(head,p); } else if(order == 'Q') { char name[21];
cin>>name; del(head,name); } else if(order == 'C') { N *p = creat(); cin>>p->name>>p->data; change(head,p); } else if(order == 'S') { output(head); } } output_rank(head); return 0;}
- SDUT—2057 模拟题
- 【模拟细节毕业题】SDUT 2411——Pixel density
- sdut 3567 模拟
- SDUT 1133 模拟计算器
- 模拟SDUT OJ登陆
- SDUT 3183 (More) Multiplication(模拟)
- sdut-2156(模拟,bfs)
- SDUT 2167 Mathman Bank 模拟
- sdut 3567 Memory Leak 模拟
- Sdut 2409 The Best Seat in ACM Contest(山东省第三届ACM省赛 H 题)(模拟)
- SDUT 2411——Pixel density模拟细节WA了n遍
- SDUT 2085 ——翻转吧!字符串 STRTOK函数应用 模拟
- 【MAP模拟】SDUT 1471 A + B problem
- SDUT 2087 离散事件模拟-银行管理
- sdut 2624 Contest Print Server (模拟)
- SDUT 3165 Round Robina(模拟)
- SDUT 2411 Pixel density(模拟,字符串)
- SDUT 2087 离散事件模拟-银行管理
- SDUT 2408 Pick apples
- HDU 1166 敌兵布阵
- HDU1754 I Hate It 点修改 区间查询 模板题
- HDU 1264 Counting Squares
- 面积并问题 HDU 1542 Atlantis
- SDUT—2057 模拟题
- Android杂谈---获取手机屏幕大小
- SDUT1482——二元多项式
- Message Flood SDUT 1500
- 编码过程中积累的代码总结
- SDUT 216 数据结构实验之二叉树的建立与遍历
- SDUT 2129 树结构练习——判断给定森林中有多少棵树
- 技术架构师要有责任心
- mac首次登陆操作