Ceceliaaa 2023-04-02 17:28 采纳率: 66.7%
浏览 102
已结题

不知道带什么标题好随便搞一个吧

@滴水不穿石 转专业模拟考试的题,有点点没思路,感谢!顺便问问一下能不能推荐点转专业可能会出的timu,已经学习了高精度乘法,冒泡排序,高精度加法,分解质因数但是觉得还远远不够

img

img

  • 写回答

5条回答 默认 最新

  • 滴水不穿石 2023-04-02 22:52
    关注

    希望对你有帮助,代码仅供参考!有问题多谢提出!谢谢!

    img

    img

    img

    img

    #include <stdio.h>
    #include <time.h>
    #include <string.h>
    struct
    {
        int year;
        int mon;
        int mday;
    } ys[5];
    
    const int arr[15] = { 1868, 9, 8, 1912, 7, 30, 1926, 12, 25, 1989, 1, 8, 2019, 5, 1 };
    
    int main(int argc, char *argv[])
    {
        // 初始化日本五个纪年日期
        for (int i = 0, j = 0; i < 5; i++)
        {
            ys[i].year = arr[j++];
            ys[i].mon = arr[j++];
            ys[i].mday = arr[j++];
        }
        char ch;
        int y, m, md, n;
        scanf("%c%d/%d/%d%d", &ch, &y, &m, &md, &n);
        switch (ch)
        {
        case 'M':
            y += ys[0].year - 1;
            break;
        case 'T':
            y += ys[1].year - 1;
            break;
        case 'S':
            y += ys[2].year - 1;
            break;
        case 'H':
            y += ys[3].year - 1;
            break;
        case 'R':
            y += ys[4].year - 1;
            break;
        default:
            puts("输入有误!");
            return -1;
        }
        time_t t, tim[5];
        struct tm tt, tt2[5];
        tt.tm_year = y - 1900;
        tt.tm_mon = m - 1;
        tt.tm_mday = md + n;
        tt.tm_hour = 23;
        tt.tm_min = 0;
        tt.tm_sec= 0;
    
        // 转成秒
        t = mktime(&tt);
    
        for (int i = 0; i < 5; i++)
        {
            tt2[i].tm_year = ys[i].year - 1900;
            tt2[i].tm_mon = ys[i].mon - 1;
            tt2[i].tm_mday = ys[i].mday;
            tt2[i].tm_hour = 0;
            tt2[i].tm_min=0;
            tt2[i].tm_sec=0;
            tim[i] = mktime(&tt2[i]);
        }
        // 重新输出具体日期
        char no;
        // t tim
        if (t >= tim[4])
        {
            no = 'R';
            tt.tm_year += -118;
        }
        else if (t >= tim[3] && t < tim[4])
        {
            no = 'H';
            tt.tm_year += -88;
        }
        else if (t >= tim[2] && t < tim[3])
        {
            no = 'S';
            tt.tm_year += -25;
        }
        else if (t >= tim[1] && t < tim[2])
        {
            no = 'T';
            tt.tm_year += -11;
        }
        else if (t < tim[1])
        {
            no = 'M';
            tt.tm_year += 33;
        }
        // 输出
        printf("%c%d/%d/%d", no, tt.tm_year, tt.tm_mon + 1, tt.tm_mday);
        return 0;
    }
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录
查看更多回答(4条)

报告相同问题?

问题事件

  • 系统已结题 4月11日
  • 已采纳回答 4月3日
  • 创建了问题 4月2日

悬赏问题

  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 MATLAB中streamslice问题
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 51单片机中C语言怎么做到下面类似的功能的函数(相关搜索:c语言)
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序