题解 | 获得月份天数
获得月份天数
https://www.nowcoder.com/practice/13aeae34f8ed4697960f7cfc80f9f7f6
#include <stdio.h>
void text(int a,int b)
{
int c=0;
int arr[]={0,31,28,31,30,31,30,31,31,30,31,30,31};
c=arr[b];
if((a%4==0&&a%100!=0)||(a%400==0)&&(b==2))
{
c+=1;
}
printf("%d\n",c);
}
int main() {
int a, b;
while (scanf("%d %d", &a, &b) != EOF) { // 注意 while 处理多个 case
// 64 位输出请用 printf("%lld") to
text(a,b);
}
return 0;
}
查看9道真题和解析