输入年月日,计算这一天是一年的第几天?
作者:互联网
#include<stdio.h> int main() { int a[12]={31,28,31,30,31,30,31,31,30,31,30,31}; int num; int years,months,days,i,j=0,flag = 1; scanf("%d-%d-%d",&years,&months,&days); if(years%4==0&&years%100!=0||years%400==0) { a[1] = 29; } for(i=0;i<months-1;i++) { j+=a[i]; } num=j+days; printf("%d",num); }
标签:-%,第几天,int,31,30,years,年月日,years%,输入 来源: https://www.cnblogs.com/HPUjingchen/p/16436983.html