L1-043. 阅览室

这是一个C++程序,用于记录并计算阅览室的使用情况。程序读取输入的天数,每天的开始(S)和结束(E)时间,最后输出每天的使用人数及平均使用分钟数。通过cal函数计算两个时间点之间的时长差距,并用memset初始化存储时间的数据结构。
摘要由CSDN通过智能技术生成
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>

using namespace std;

int sh[1005],sm[1005];

struct ans{
  int num;
  int ms;
}ans[1005];

int cal(int sh,int sm,int eh,int em){
  return (eh * 60 + em) - (sh * 60 + sm);
}
int main(void){
  memset(sh,-1,sizeof(sh));
    memset(sm,-1,sizeof(sm));
  int day;
  scanf("%d",&day);
  int cnt = 0;
  int idd,h,m;
  char op[2];
  int cntt = 0;
  int total = 0;
  int acnt = 0;
  while(cnt < day){
    scanf("%d",&idd);
    
    if(idd == 0){
      cnt++;

      scanf("%s",op);
        scanf("%d:%d",&h,&m);
        ans[acnt].num = cntt;
        if(cntt != 0){
           double temp1 = (double)total / (double) cntt;
           int temp2 = total / cntt;
           ans[acnt++].ms = temp1 >= (temp2 + 0.5)? temp2 + 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值