fork download
  1. #include <stdio.h>
  2.  
  3. int Leap(int year) {
  4. if (year % 400 == 0) return 1; // 400で割り切れる → 閏年
  5. else if (year % 100 == 0) return 0; // 100で割り切れる → 平年
  6. else if (year % 4 == 0) return 1; // 4で割り切れる → 閏年
  7. else return 0; // その他 → 平年
  8. }
  9.  
  10. int main() {
  11. int year;
  12.  
  13. printf("西暦年を入力してください: ");
  14. scanf("%d", &year);
  15.  
  16. if (Leap(year))
  17. printf("%d年は閏年です。\n", year);
  18. else
  19. printf("%d年は平年です。\n", year);
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0.01s 5308KB
stdin
Standard input is empty
stdout
西暦年を入力してください: 32767年は平年です。