#include #include #include #include

using namespace std;

struct Record { int bookId; char key; int hour; int minute; };

int main() { int N; cin >> N;

for (int i = 0; i < N; i++) {
    int borrowCount = 0;
    int borrowTime = 0;
    int lastHour = 0;
    int lastMinute = 0;
    map<int, Record> borrowRecords;
    
    while (true) {
        int bookId;
        char key;
        int hour;
        int minute;
        cin >> bookId >> key >> hour >> minute;
        
        if (bookId == 0) {
            if (borrowCount > 0) {
                cout << borrowCount << " " << borrowTime / borrowCount << endl;
            } else {
                cout << "0 0" << endl;
            }
            break;
        }
        
        if (key == 'S') {
            Record record;
            record.bookId = bookId;
            record.key = key;
            record.hour = hour;
            record.minute = minute;
            borrowRecords[bookId] = record;
        } else if (key == 'E') {
            if (borrowRecords.find(bookId) != borrowRecords.end()) {
                Record record = borrowRecords[bookId];
                borrowRecords.erase(bookId);
                
                int borrowDuration = (hour - record.hour) * 60 + (minute - record.minute);
                if (borrowDuration >= 0) {
                    borrowCount++;
                    borrowTime += borrowDuration;
                }
            }
        }
    }
}

return 0;
c++写程序:天梯图书阅览室请你编写一个简单的图书借阅统计程序。当读者借书时管理员输入书号并按下S键程序开始计时;当读者还书时管理员输入书号并按下E键程序结束计时。书号为不超过1000的正整数。当管理员将0作为书号输入时表示一天工作结束你的程序应输出当天的读者借书次数和平均阅读时间。注意:由于线路偶尔会有故障可能出现不完整的纪录即只有S没有E或者只有E没有S的纪录系统应能自动忽略这种无效纪录。另外

原文地址: https://www.cveoy.top/t/topic/hQt3 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录