函式_閏年平年判斷

 avatar
user_3763047219
c_cpp
2 years ago
415 B
0
Indexable
Never
void years(int year);

#include <stdio.h>
#include <stdlib.h>
void years(int year) {
    if (year % 4 == 0 && year % 100 != 0) {
        printf("%d是閏年",year);
    }
    else if (year % 400 == 0) {
        printf("%d是閏年", year);
    }
    else {
        printf("%d是平年", year);
    }
}




int main() {
    int year;
    scanf("%d", &year);
    years(year);
    return 0;
}