UVa12541 - Birthdates(排序)

本文介绍了一个程序设计问题,即如何通过输入的姓名及出生日期数据来确定一组人员中谁是最年轻和最年长的人。该程序使用C++编写,包括输入处理、数据结构定义以及排序算法的应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Write a program to identify the youngest person and the oldest person in a class.
Input
The number n (1 n 100) in the rst line determines the number of people in a class. The following
n lines contain person's name and his/her birthdate.
The information in each line is of this format:
personN ame dd mm yyyy
where personN ame is a single word less than 15 letters, dd mm yyyy are date, month and year of the
birthdate.
Suppose that no one has the same name or the same birthdate.
Output
Print out 2 lines containing the name of youngest person and oldest person, respectively.
Sample Input
5
Mickey 1 10 1991
Alice 30 12 1990
Tom 15 8 1993
Jerry 18 9 1990
Garfield 20 9 1990
Sample Output
Tom
Jerry

#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>

using namespace std;

const int N = 20;

struct Person
{
    string name;
    int year, month, day;

    bool operator < (const Person &other) const
    {
        if (year != other.year) return year > other.year;

        if (month != other.month) return month > other.month;

        if (day != other.day) return day > other.day;

        return name < other.name;
    }
};

vector<Person> persons;

void input();
void solve();


int main()
{
#ifndef ONLINE_JUDGE
    freopen("e:\\uva_in.txt", "r", stdin);
#endif

    input();
    solve();

    return 0;
}

void input()
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        char name[N];
        int d, m, y;
        scanf("%s%d%d%d", name, &d, &m, &y);
        persons.push_back((Person){name, y, m, d});
    }
}



void solve()
{
    sort(persons.begin(), persons.end());

    printf("%s\n%s\n", persons.front().name.c_str(), persons.back().name.c_str());
}


 

 

标题基于SpringBoot的在线网络学习平台研究AI更换标题第1章引言介绍基于SpringBoot的在线网络学习平台的研究背景、意义、国内外现状、论文研究方法及创新点。1.1研究背景与意义阐述在线网络学习平台的重要性及其在教育领域的应用价值。1.2国内外研究现状分析当前国内外在线网络学习平台的发展状况及趋势。1.3研究方法与创新点说明本研究采用的方法论和在研究过程中的创新之处。第2章相关理论技术概述SpringBoot框架、在线教育理论及相关技术基础。2.1SpringBoot框架概述介绍SpringBoot框架的特点、优势及其在Web应用中的作用。2.2在线教育理论阐述在线教育的基本理念、教学模式及其与传统教育的区别。2.3相关技术基础介绍开发在线网络学习平台所需的关键技术,如前端技术、数据库技术等。第3章在线网络学习平台设计详细描述基于SpringBoot的在线网络学习平台的整体设计方案。3.1平台架构设计给出平台的整体架构图,并解释各个模块的功能及相互关系。3.2功能模块设计详细介绍平台的主要功能模块,如课程管理、用户管理、在线考试等。3.3数据库设计说明平台的数据库设计方案,包括数据表结构、数据关系等。第4章平台实现与测试阐述平台的实现过程及测试方法。4.1平台实现详细介绍平台的开发环境、开发工具及实现步骤。4.2功能测试对平台的主要功能进行测试,确保功能正常且符合预期要求。4.3性能测试对平台的性能进行测试,包括响应时间、并发用户数等指标。第5章平台应用与分析分析平台在实际应用中的效果及存在的问题,并提出改进建议。5.1平台应用效果介绍平台在实际教学中的应用情况,包括用户反馈、使用情况等。5.2存在问题及原因分析分析平台在运行过程中出现的问题及其原因,如技术瓶颈、用户体验等。5.3改进建议与措施针对存在的问题提出具体的改进建议和措施,以提高平台的性能和用户满意度
要在微信小程序中实现这样的功能,你可以按照以下步骤创建一个表单页面: 1. **导入所需组件**: 首先,在`pages/index.wxml`文件中引入需要的表单组件,如`view`, `input`, `radio`, `picker`, 和 `checkbox`。 ```wxml <view class="container"> <!-- 姓名 --> <view class="item"> <label>姓名:</label> <input type="text" placeholder="请输入姓名" bindInput="handleNameChange" /> </view> <!-- 性别 --> <view class="item"> <label>性别:</label> <radio-group value="{{sex}}" bindchange="handleSexChange"> <radio value="male">男</radio> <radio value="female">女</radio> </radio-group> </view> <!-- 出生日期 --> <view class="item"> <label>出生日期:</label> <picker bindchange="handleBirthDateChange" range="{{birthDates}}"></picker> </view> <!-- 邮箱 --> <view class="item"> <label>邮箱:</label> <input type="email" placeholder="请输入邮箱" bindInput="handleEmailChange" /> </view> <!-- 爱好 --> <view class="item"> <label>爱好:</label> <checkbox-group checkedData="{{hobbies}}"> <checkbox value="reading">阅读</checkbox> <checkbox value="sports">运动</checkbox> <checkbox value="music">音乐</checkbox> <!-- 添加更多选项... --> </checkbox-group> </view> <!-- 提交按钮 --> <button open-type="primary" bindtap="handleSubmit">提交</button> <!-- 显示结果区域 --> <view class="result" hidden="{{showResult ? '' : 'hidden'}}"> <p>姓名:{{name}}</p> <p>性别:{{sex}}</p> <p>出生日期:{{selectedDate}}</p> <p>邮箱:{{email}}</p> <p>爱好:{{hobbies.join(', ')}}</p> </view> </view> ``` 2. **设置数据状态**: 在`pages/index.js`中初始化必要的变量,并处理数据变化的事件。 ```javascript Page({ data: { name: '', sex: '', selectedDate: '', email: '', hobbies: ['reading', 'sports'], birthDates: ['1900-01-01', '2023-12-31'], // 示例范围 showResult: false, }, // ...其他事件处理器 handleSubmit(e) { this.setData({ showResult: true, // 展示结果区域 }); console.log('提交信息:', { name: this.data.name, sex: this.data.sex, email: this.data.email, hobbies: this.data.hobbies }); // 实际应用中可以将数据发送到服务器或本地存储 }, handleNameChange(e) { this.setData({ name: e.detail.value }); }, // ...其他事件处理器 }); ``` 3. **样式设置**: 在`styles.wxss`文件中添加一些基本样式来美化页面布局。 以上代码示例展示了如何在一个微信小程序页面中实现所需的表单功能。用户填写信息后,点击提交按钮会显示填写的信息,并隐藏提交按钮下方的结果区域。可以根据实际需求调整样式和数据结构。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kgduu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值