0
点赞
收藏
分享

微信扫一扫

L1-3-嵌套循环 / if-else 阅览室 (20 分)

荷一居茶生活 2022-03-22 阅读 35
算法

时隔多年,也是终于纯纯靠自己写出来了,这种感觉确实是比当初背代码的感觉要好一些。哎,还是得要纯纯地靠自己思考下刷题才是有效的啊。

#include<bits/stdc++.h>
using namespace std;
const int N = 1e3+10;
struct shu{
    int time;
    int st;
    
}shus[N];

struct day{
    int cnt;
    int total;
    int pj;
}days[20];

int main(){
    int n;
    cin>>n;
    int shuhao;
    char caozuo;
    int hh,mm;
    for(int i=0;i<n;){
        scanf("%d %c %d:%d",&shuhao,&caozuo,&hh,&mm);
        if(caozuo == 'S'){
            shus[shuhao].time = hh * 60 + mm;
            shus[shuhao].st = 1;
        }
        if(caozuo == 'E'){
            if(shus[shuhao].st == 1){
                days[i].cnt++;
                days[i].total += hh * 60 + mm - shus[shuhao].time;
                shus[shuhao].st = 0;
            }
        }
        if(shuhao == 0){
            double l = days[i].cnt;
            double p = days[i].total;
            if(l == 0){
                cout<<0<<" "<<0<<endl;
            }
            else{
                cout<<l<<" "<<int(p/l + 0.5) <<endl;
            }
            i++;
            memset(shus , 0 ,sizeof shus);
        }
    }
}
举报

相关推荐

L1-043 阅览室 (20 分)

L1-043 阅览室 (20 分)坑

L1-3 阅览室

L1-043 阅览室

阅览室pta(详解)

Javascript 循环 if if-else switch

0 条评论