题解 | #今年的第几天?#
今年的第几天?
https://www.nowcoder.com/practice/ae7e58fe24b14d1386e13e7d70eaf04d
#include <stdio.h> int main(){ int Month[13] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int year, month, day; while (scanf("%d %d %d", &year, &month, &day) != EOF){ int total = 0; if(month == 1){ printf("%d\n", day); } else{ for (int i = 0; i < month - 1; ++i) { total += Month[i]; } total += day; if(month > 2 && year % 100 != 0 && year % 4 == 0 || year % 400 == 0){ total++; } printf("%d\n", total); } } return 0; }