题解 | 获得月份天数

获得月份天数

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;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务