P8722 [蓝桥杯 2020 省 AB3] 日期识别
- 链接
- 题目
- 代码
链接
添加链接描述
题目
代码
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <queue>
#include <climits> // 包含INT_MAX常量
#include <cctype>
using namespace std;string a[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};int main() {string s;cin >> s;int result = 0;string month = s.substr(0, 3);for (int i = 0; i < 12; i++) {if (month == a[i]) {result = i + 1;break;}}string day = s.substr(3, 5);cout << result << ' ';if (day[0] != '0')cout << day[0];cout << day[1];return 0;
}