当前位置:网站首页>C171: attendance system
C171: attendance system
2022-07-27 20:01:00 【Qiangan】
Problem description
The laboratory uses the attendance system to check the attendance of students . The attendance system will record the time of each student entering and leaving the laboratory every time in a day .
Each student has a unique number , Each attendance record includes the student's number , Entry time 、 Time to leave .
Give the attendance records of all students for one day , Please count the time each student works in the laboratory , And give a statistical table of one day according to the working hours from long to short , When the working hours are the same, they are sorted according to the number from small to large .
Enter description
The first line of input contains an integer n, Indicates the number of attendance records .1≤n≤100, The number of students is no more than 100 The positive integer .
Next is n That's ok , Each line is an attendance record , Each record includes the student number k, Entry time t1 And departure time t2 Three items .
t1 and t2 The format is “hh:mm”, Two digit hours and two digit minutes . for example 14:20 It means 2:20 p.m , All times are 24 hourly , And they are all within the same day .
The output shows that
Output statistics sorted by working hours and student numbers . The statistics table contains several rows , Attendance records of each student , It consists of student number and total working hours , The total working time is in minutes .
sample input
5
3 08:00 11:50
1 09:00 12:00
3 13:50 17:30
1 14:00 18:00
2 17:00 24:00
sample output
3 450
1 420
2 420
#include<stdio.h>
int main()
{
int n,i,j,j1,j2,c1,c2,k;
struct stu
{
int h;
int z;
}l[100],t;
scanf("%d",&n);
k=n;
for(i=0;i<n;i++)
{
scanf("%d %d:%d %d:%d",&l[i].h,&j1,&j2,&c1,&c2);
l[i].z=c1*60+c2-j1*60-j2;
}
for(i=1;i<n;i++)
{
for(j=0;j<i;j++)
{
if(l[i].h==l[j].h)
{
l[j].z+=l[i].z;
l[i].z=0;
l[i].h=0;
}
}
}
for(i=0;i<n-1;i++)
{
for(j=0;j<n-1-i;j++)
{
if(l[j].z<l[j+1].z)
{
t=l[j];l[j]=l[j+1];l[j+1]=t;
}
else if(l[j].z==l[j+1].z)
{
if(l[j].h>l[j+1].h)
{
t=l[j];l[j]=l[j+1];l[j+1]=t;
}
}
}
}
for(i=0;i<n;i++)
{
if(l[i].h!=0) printf("%d %d\n",l[i].h,l[i].z);
}
return 0;
}
边栏推荐
- VALN 11.9
- Qt的QTextToSpeech类实现语音播报功能
- Intent (whether there is return value to jump)
- C170:复试筛选
- 1.2、基于增量式生成遮挡与对抗抑制的行人再识别(代码理解与实验进度+报告)
- MySQL time zone problem
- 2022爱分析·智慧社区厂商全景报告 厂商征集
- Hacker introductory tutorial (very detailed) from zero basic introduction to proficiency, it is enough to read this one.
- transformers-bert
- Arrayadapter (array adapter) and simpleadapter (simple adapter)
猜你喜欢

成年人只有一份主业是要付出代价的,被人事劝退后,我哭了一整晚

高手勿进!写给初中级程序员以及还在大学修炼的“准程序员”的成长秘籍

疫情下我离职一年,收入增长了10倍

C# 后台GC 的前因后果

新库上线 | CnOpenData中国全部专利详细地址数据

电容串联与并联以及电容串联与平衡电阻

Gestureoverlayview (gesture recognition 2)

Chemical giant BASF & Pasqual: using quantum neural network to optimize weather forecast

Sqlife (database)

Detailed interpretation of IEC104 protocol (I) protocol structure
随机推荐
Session攻击
SQLite SQL writing method of creating table joint primary key
How to encrypt the data in MySQL database? Mysql8.0 comes with new features
【OpenBMC 系列】4.启动流程 使用qume模拟ast2600-evb
11.2DHCP
Gesturedetector (gesture recognition)
Cesium常用坐标系详细介绍
Overview of deep active learning 2020
DNSSEC verification with dig [verify DNSSEC with dig]
Hyperledger caliper is built on fabric for performance test
Togglebutton (button switch)
Static test. 2021.01 .13
统一建模语言 (UML) 规范
11.5.OSPF
Sharepreference (storage)
Container summary
Adults have only one main job, but they have to pay a price. I was persuaded to step back by personnel, and I cried all night
聊聊 Redis 是如何进行请求处理
由单片机XTALIN引脚和XTALOUT引脚导出的对晶体震荡电路的深入理解
Software configuration | tigervnc download, installation and configuration