-
Notifications
You must be signed in to change notification settings - Fork 0
/
B1014.cpp
102 lines (59 loc) · 1.13 KB
/
B1014.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <iostream>
#include <string>
using namespace std;
int main()
{
string a, b, c, d;
cin>>a>>b>>c>>d;
int lena = a.length();
int lenb = b.length();
int min1 = lena < lenb ? lena : lenb;
int lenc = c.length();
int lend = d.length();
int min2 = lenc < lend ? lenc : lend;
char t[2];
int pos;
int j;
for(int i = 0; i < min1; i++){
if(a[i] == b[i] && (a[i] >= 'A' && a[i] <= 'G')){
t[0] = a[i];
a[i] = '#';
j = i;
break;
}
}
for(int i = j+1; i < min1; i++){
if(a[i] == b[i] && ((a[i] >= 'A' && a[i] <= 'N') || (a[i] >= '0' && a[i] <= '9'))){
t[1] = a[i];
break;
}
}
for(int i = 0; i < min2; i++){
if(c[i] == d[i] && ((c[i] >= 'A' && c[i] <= 'Z') || (c[i] >= 'a' && c[i] <= 'z'))){
pos = i;
break;
}
}
string week[7] = {"MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"};
int m;
if(t[1] >= '0' && t[1] <= '9'){
m = t[1] - '0';
}
else{
m = t[1] - 'A' + 10;
}
cout<<week[t[0] - 'A']<<" ";
if(m >= 0 && m<= 9){
cout<<0<<m<<":";
}
else{
cout<<m<<":";
}
if(pos >= 0 && pos <= 9){
cout<<0<<pos;
}
else{
cout<<pos;
}
return 0;
}