AcWing 2876. 日期识别
原题链接
简单
作者:
Nazarena
,
2021-01-17 17:21:30
,
所有人可见
,
阅读 390
C++ 代码
#include<iostream>
using namespace std;
int judge(char a, char b, char c)
{
if(a == 'J') //1,6,7
{
if(b == 'a')
return 1;
else
{
if(c == 'n')
return 6;
else
return 7;
}
}
else if(a == 'F')
return 2;
else if(a == 'M') //3,5
{
if(c == 'r')
return 3;
else
return 5;
}
else if(a == 'A') //4,8
{
if(b == 'p')
return 4;
else
return 8;
}
else if(a == 'S')
return 9;
else if(a == 'O')
return 10;
else if(a == 'N')
return 11;
else
return 12;
}
int main()
{
string s;
int m,d,t;
cin >> s;
m = judge(s[0],s[1],s[2]);
if(s[3] - '0' == 0)
d = s[4] - '0';
else
d = (s[3] - '0') * 10 + s[4] - '0';
cout << m << " " << d;
return 0;
}