游船出租.txt
来自「浙江大学研究生复试上机题目及解答。欢迎大家下载。」· 文本 代码 · 共 41 行
TXT
41 行
//test
#include <cstdio>
#include <string>
#include <cmath>
#include <stack>
#include <algorithm>
using namespace std;
bool boat[110];
int start[110];
int key,but,h,m;
int hire,ctime;
int main() {
hire = ctime = 0;
memset(boat,false,sizeof(boat));
while (scanf("%d",&key), key!=-1) {
if (key == 0) {
scanf(" %c %d:%d",&but,&h,&m);
if (hire == 0) puts("0 0");
else printf("%d %.0lf\n",hire,1.0*ctime/hire);
hire = ctime = 0;
memset(boat,false,sizeof(boat));
}
else {
scanf(" %c %d:%d",&but,&h,&m);
if (but == 'S') {
if (!boat[key]) {
start[key] = 60*h +m;
boat[key] = true;
}
}
else {
if (boat[key]) {
boat[key] = false;
hire ++;
ctime += 60*h+m - start[key];
}
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?