第十一届蓝桥杯省赛第三场C++A/B组
复习一下substr的用法:
string s = “0123456789”;
- string s1 = s.substr(5); //只有一个数字5表示从下标为5开始一直到结尾,即s1 = “56789”
- string s2 = s.substr(5,3) //从下标为5开始截取长度为3位,即s2 = “567”
#include<iostream>
using namespace std;
string a,b;
int main()
{
cin>>a;
b=a.substr(0,3);
int x=a[3]-'0',y=a[4]-'0',s=0,k=0;
if(x!=0)s=x*10+y;
else s=y;
if(b=="Jan")k=1;
if(b=="Feb")k=2;
if(b=="Mar")k=3;
if(b=="Apr")k=4;
if(b=="May")k=5;
if(b=="Jun")k=6;
if(b=="Jul")k=7;
if(b=="Aug")k=8;
if(b=="Sep")k=9;
if(b=="Oct")k=10;
if(b=="Nov")k=11;
if(b=="Dec")k=12;
cout<<k<<" "<<s;
return 0;
}