首页 > 试题广场 >

最小年龄的3个职工

[编程题]最小年龄的3个职工
  • 热度指数:11643 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 64M,其他语言128M
  • 算法知识视频讲解
职工有职工号,姓名,年龄.输入n个职工的信息,找出3个年龄最小的职工打印出来。

输入描述:
输入第一行包括1个整数N,3<=N<=30,代表输入数据的个数。
接下来的N行有N个职工的信息:
包括职工号(整数), 姓名(字符串,长度不超过10), 年龄(1<=age<=100)。


输出描述:
可能有多组测试数据,对于每组数据,
输出结果行数为N和3的较小值,分别为年龄最小的职工的信息。
关键字顺序:年龄>工号>姓名,从小到大。
示例1

输入

5
501 Jack 6
102 Nathon 100
599 Lily 79
923 Lucy 15
814 Mickle 65

输出

501 Jack 6
923 Lucy 15
814 Mickle 65
头像 ETO~元
发表于 2022-03-18 11:26:54
6ms 464kb 用时比较长 #include <iostream> #include <string> #include<algorithm> using namespace std; struct stuff {     int 展开全文
头像 在考古的小鱼干很有气魄
发表于 2023-03-07 10:27:58
#include <bits/stdc++.h> #define MAX 30 using namespace std; typedef struct worker { int num; string name; int age; } worker; bool 展开全文
头像 陈方长
发表于 2023-03-02 16:50:59
#include<bits/stdc++.h> using namespace std; struct worker { int num; string name; int age; } er[100]; bool cmp(worker a, worker b 展开全文
头像 踏实的布莱恩在做测评
发表于 2024-03-14 13:25:51
#include <bits/stdc++.h> using namespace std; struct stuff{ int num,age; string name; }; bool cmp(stuff A,stuff B) { if(A.age!=B.age 展开全文
头像 牛客218094273号
发表于 2024-03-18 16:14:44
#include<iostream> #include<algorithm> #include<string.h> using namespace std; struct worker { int id; char name[11]; in 展开全文
头像 给我就亿下
发表于 2023-03-23 19:43:09
#include <iostream> #include <algorithm> using namespace std; struct staff{ int id; string name; int age; }; staff s[31]; bool cmp(s 展开全文
头像 小朱666
发表于 2023-09-22 19:08:22
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<iostream> #include<algorithm> using namespace std; typ 展开全文
头像 拒绝996的小松鼠很想奋斗
发表于 2024-02-29 22:40:29
#include <stdio.h> struct worker{ int number; char name[10]; int age; }; int min(int x,int y) { if(x>y) return y; el 展开全文
头像 wbc990512
发表于 2021-01-22 12:32:49
#include <stdio.h> #include<stdlib.h> #include<string.h> typedef struct{ int id; char name[20]; int age; }Staff,*snode; 展开全文
头像 whoway
发表于 2020-12-27 15:58:21
return ( strcmp(a.name, b.name)<0 )? true : false;记忆 #include<bits/stdc++.h> using namespace std; int n; struct node { int num; cha 展开全文