日期计算

来源:互联网 发布:趣头条提现是骗局 知乎 编辑:程序博客网 时间:2024/04/30 17:22
#include<stdio.h>
int isRun(int year){
if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
return 1;
return 0;
}
int main(){
int t;
scanf("%d", &t);
while (t--){
int month[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int a, b, c;
int sum = 0, i;
scanf("%d%d%d", &a, &b, &c);
if (isRun(a))
month[2] = 29;
for (i = 1; i < b; i++){
sum += month[i];
}
printf("%d\n", sum + c);
}
return 0;
}
0 0
原创粉丝点击