P8722 [蓝桥杯 2020 省 AB3] 日期识别--2024蓝桥杯冲刺省一

点击跳转例题

知识点:字符串总结

注意事项在代码中

#include <bits/stdc++.h>
#define int long long //(有超时风险)
#define PII pair<int,int>
#define endl '\n'
#define LL __int128

using namespace std;

const int N=2e6+10,M=1e3+10,mod=998244353,INF=0x3f3f3f3f;

int a[N],b[N],c[N],pre[N];

signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    string s;cin>>s;
    string str[]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};

    //表示第0位开始3个字符
    //判断月份
    string tmp=s.substr(0,3);
    for(int i=0;i<12;i++)
    {
        if(str[i]==tmp)
            cout<<i+1<<' ';
    }
    //第3位开始到最后得字符串
    //判读日
    string ans=s.substr(3);
    for(int i=0;i<ans.size();i++)
    {
        if(i==0&&ans[i]=='0')
            continue;
        cout<<ans[i];
    }

    return 0;
}

相关推荐

最近更新

  1. TCP协议是安全的吗?

    2024-02-05 15:32:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-02-05 15:32:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-02-05 15:32:02       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-02-05 15:32:02       20 阅读

热门阅读

  1. 25.泛型

    25.泛型

    2024-02-05 15:32:02      19 阅读
  2. Python教程|input()函数—输入(一):语法说明

    2024-02-05 15:32:02       30 阅读
  3. 1688商品详情页

    2024-02-05 15:32:02       24 阅读
  4. C&C++语言define和const区别

    2024-02-05 15:32:02       30 阅读
  5. PyTorch、NCNN、CV::Mat三者张量的shape

    2024-02-05 15:32:02       26 阅读