a004. 文文的求婚
C語言參考解答
c
#include<stdio.h>
int main() {
int n;
while(scanf("%d", &n) != EOF){
int result = 1;
if (n % 400 == 0);
else if (n % 100 == 0) result = 0;
else if (n % 4 == 0);
else result = 0;
if (result == 1) printf("閏年\n");
else printf("平年\n");
}
}C++參考解答
cpp
#include<bits/stdc++.h>
using namespace std;
int main() {
int n;
while(cin >> n){
string result = "閏年";
if (n % 400 == 0);
else if (n % 100 == 0) result = "平年";
else if (n % 4 == 0);
else result = "平年";
cout << result << endl;
}
}Index 搜尋關鍵字
基本輸入輸出、判斷、選擇結構、簡單、基礎、if、閏年