PATbasic1004
来源:互联网 发布:nginx set by lua 编辑:程序博客网 时间:2024/06/13 22:30
#include "stdafx.h"#include<iostream>#include<string>using namespace std;typedef struct node {string name;string number;int result;struct node *next;}NODE;NODE *build(int n) {NODE *head, *p, *nextnode;head = new NODE;head->next = NULL;p = head;for (int i = 0; i < n; i++) {nextnode = new NODE;cin >> nextnode->name;cin >> nextnode->number;cin >> nextnode->result;p->next = nextnode;p = nextnode;}p->next = NULL;return head;}void sort(NODE *head) {NODE *min = head->next, *max = head->next;NODE *p;for (p = head->next->next; p != NULL; p = p->next) {if (p->result > max->result) {max = p;}}for (p = head->next->next; p != NULL; p = p->next) {if (p->result < min->result) {min = p;}}cout << max->name << " " << max->number << endl;cout << min->name << " " << min->number << endl;}int main(){int n;cin >> n;NODE *head = build(n);sort(head); return 0;}这题我做麻烦了。。。其实完全用不着链表的,用一个NODE array[]存所有的节点然后排个序OK。万恶的惯性思维。。。
阅读全文
0 0
- PATbasic1004
- PATbasic1004. 成绩排名 (20)待改正
- tensorflow1.3.0安装注意
- StampedLock的简单用法
- 谈谈刚被西数吞并的闪存公司——Tegile System
- java实现二叉树,以及二叉树的遍历和先序和后序求解
- 编码格式简介:ASCII码、ANSI、GBK、GB2312、GB18030和Unicode、UTF-8,BOM头
- PATbasic1004
- 方向梯度直方图(HOG,Histogram of Gradient)
- 【Mybatis】——foreach使用方式
- bzoj 4574: [Zjoi2016]线段树 动态规划
- 石家庄一中游记(2017暑假)
- python+scrapy安装教程
- 1033:立方和不等式
- 感悟——写在研二初
- python