2022.11.02 PM 02:00 by CBJ
來源 : https://zerojudge.tw/ShowProblem?problemid=a004 出題者 : Zerojudge 標籤 : 曆法 難易度 : 0.1
解題想法 : 閏年判斷(常識題) 閏年判斷參考 : https://zh.wikipedia.org/zh-tw/%E9%97%B0%E5%B9%B4#%E9%96%8F%E5%B9%B4%E8%A6%8F%E5%89%87
//C language
//solution link(含註解): https://github.com/CBJ0519/CBJsProgramDiary.com/blob/main/zj/a004.c
#include<stdio.h>
int main(){
int year;
while(scanf("%d",&year)!=EOF){
if((year%4==0 && year%100) || year%400==0) printf("閏年\n");
else printf("平年\n");
}
return 0;
}

//C++ language
//solution link(含註解): https://github.com/CBJ0519/CBJsProgramDiary.com/blob/main/zj/a004.cpp
#include<iostream>
using namespace std;
int main(){
int year;
while(cin>>year){
if((year%4==0 and year%100) or year%400==0) cout<<"閏年\n";
else cout<<"平年\n";
}
return 0;
}

## Python language
## solution link(含註解): https://github.com/CBJ0519/CBJsProgramDiary.com/blob/main/zj/a004.py
from sys import stdin
for read in stdin:
year=int(read)
if (year%4==0 and year%100) or year%400==0: print('閏年')
else: print('平年')

發佈留言