题解 | #计算日期到天数转换#
计算日期到天数转换
https://www.nowcoder.com/practice/769d45d455fe40b385ba32f97e7bcded
#include <stdio.h> int main() { int a, b,c; while (scanf("%d %d %d", &a, &b,&c) != EOF) { // 注意 while 处理多个 case int arr[12] = {31,28,31,30,31,30,31,31,30,31,30,31}; if((a%4 == 0 && a%100 != 0) || a%400 == 0) arr[1] = 29; int sum = 0; for(int i = 0;i < b-1;i++) { sum += arr[i]; } printf("%d",sum+c); } return 0; }
只能说泰裤辣,还有谁比我代码简洁吗哈哈哈