超大型LED显示屏

时间:2022-04-11 21:47:49


超大型LED显示屏

超大型LED显示屏

超大型LED显示屏

代码:

#include <iostream>
#include <map>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

int main()
{
char s[100];
map<int, int> m;
//求出比分从0到999所亮的灯管数
m[0] = 6;
m[1] = 2;
m[2] = 5;
m[3] = 5;
m[4] = 4;
m[5] = 5;
m[6] = 6;
m[7] = 3;
m[8] = 7;
m[9] = 6;
for(int i = 10; i <= 99; i++) {
m[i] = m[i%10] + m[i/10];
}
for(int i = 100; i <= 999; i++) {
m[i] = m[i%10] + m[(i/10)%10] + m[i/100];
}

int Node = 1;
while(gets(s)) {
char temp_s;
temp_s = s[1];
int result = 0;
int hour;
int minute;
int sec;
int last_time; //开始时间或者上次得分时的时间
int curr_time; //当前得分的时间
int home_number = 0;
int guest_number = 0;
while( temp_s != 'N') {
if(temp_s == 'T') { //如果是"START"
hour = (s[6]-48)*10+s[7]-48;
minute = (s[9]-48)*10 + s[10]-48;
sec = (s[12]-48)*10+s[13]-48;
last_time = (hour*60 + minute)*60+sec;
}
else
{ //输入为"SCORE"的情况
char temp_s1;
temp_s1 = s[15];
if(temp_s1 == 'h') { //"SCORE"里面"home(主场)"得分的情况
hour = (s[6]-48)*10+s[7]-48;
minute = (s[9]-48)*10 + s[10]-48;
sec = (s[12]-48)*10+s[13]-48;
curr_time = (hour*60 + minute)*60+sec;
result = result + (curr_time - last_time)*(m[home_number] + m[guest_number]);
home_number = home_number + s[20] - 48;
last_time = curr_time;
}
else
{//SCORE"里面"guest(客场)"得分的情况
hour = (s[6]-48)*10+s[7]-48;
minute = (s[9]-48)*10 + s[10]-48;
sec = (s[12]-48)*10+s[13]-48;
curr_time = (hour*60 + minute)*60+sec;
result = result + (curr_time - last_time)*(m[home_number] + m[guest_number]);
guest_number = guest_number + s[21] - 48;
last_time = curr_time;
}
}
gets(s);
temp_s = s[1];
}//当输入为"END"时,从END之前的一次"SCORE"到"END"时的情况
hour = (s[4]-48)*10+s[5]-48;
minute = (s[7]-48)*10+s[8]-48;
sec = (s[10]-48)*10+s[11]-48;
curr_time = (hour*60 + minute)*60+sec;
result = result + (curr_time - last_time)*(m[home_number] + m[guest_number]);
printf("Case %d: %d\n",Node++, result);
}
return 0;
}