#33911: C++ 解法


48985654 (天涯海神)

學校 : 不指定學校
編號 : 123240
來源 : [120.105.132.242]
最後登入時間 :
2023-03-27 09:02:37
c638. 天干地支 -- it's david | From: [123.192.84.149] | 發表日期 : 2023-02-12 17:46

#include <iostream>
using namespace std;

int main() {
    int year;
    cout << "請輸入年份:";
    cin >> year;
    int tian_gan = (year - 1800) % 10;
    int di_zhi = (year - 1800) % 12;
    string tian_gan_str[10] = {"甲", "乙", "丙", "丁", "戊", "己", "庚", "辛", "壬", "癸"};
    string di_zhi_str[12] = {"子", "丑", "寅", "卯", "辰", "巳", "午", "未", "申", "酉", "戌", "亥"};
    cout << "天干:" << tian_gan_str[tian_gan] << endl;
    cout << "地支:" << di_zhi_str[di_zhi] << endl;
    return 0;
}

 
ZeroJudge Forum