8 条题解

  • 1
    @ 2024-1-11 11:12:47
    #include<stdio.h>
    int main(){
    int x,y,ans=0;
    int yue[12]={31,28,31,30,31,30,31,31,30,31,30,31};
    scanf("%d %d",&x,&y);
    if(x % 4 == 0&& x % 100 != 0 || x % 400 == 0)
    yue[1]+=1;
    ans+=yue[y-1];
    printf("%d",ans);
    return 0;
    }``
    
    ```
    
    ```
    • 1
      @ 2023-12-7 22:51:34

      #include <stdio.h> int main() { int x,y; int flag=0; scanf("%d %d",&x,&y); int a[2][13]={{31,28,31,30,31,30,31,31,30,31,30,31},{31,29,31,30,31,30,31,31,30,31,30,31}}; if((x%40&&x%100!=0)||x%4000) flag=1; printf("%d",a[flag][y-1]); return 0; }

      • 0
        @ 2024-8-11 17:20:37

        // 处理每个月的天数 int days_in_month;

        switch (month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: days_in_month = 31; break; case 4: case 6: case 9: case 11: days_in_month = 30; break; case 2: // 判断是否是闰年 if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) { days_in_month = 29; } else { days_in_month = 28; } break; default: days_in_month = 0; // 无效的月份 break; }

        printf("%d\n", days_in_month); return 0;

        • 0
          @ 2024-4-24 22:27:15
          #include <stdio.h>
          int main()
          {
              int a,b,c;
              scanf("%d%d",&a,&b);
              if(b==1||b==3||b==5||b==7||b==8||b==10||b==12)c=31;
              else if(b==4||b==6||b==9||b==11);
              else if((a%4==0&&(a%400==0||a%100!=0))&&b==2)c=29;
              else c=28;
              printf("%d",c);
              return 0;
          }
          //
          
          • 0
            @ 2023-11-9 19:35:23
             
            #include<stdio.h>
            int main()
            {
                int year, month, days;
              
                    scanf("%d %d", &year, &month);
                switch(month)
                { case 1:
                  case 3:
                  case 5:
                  case 7:
                  case 8:
                  case 10:
                  case 12:days = 31;  break;
                  case 4:
                  case 6:
                  case 9:
                  case 11:days = 30; break;
                  case 2:
                      if (year % 400 == 0 || year % 4 == 0 && year % 100 != 0)
                          days = 29;
                      else
                          days = 28; break;
             
             
                }
                printf("%d",days);
                return 0;
            }
            
            • 0
              @ 2023-9-16 14:03:38

              #include<stdio.h> int main(){ int x,y;1<=y&&y<=12; scanf("%d %d",&x,&y); switch(y){ case 1: case 3: case 5: case 7: case 8: case 10: case 12: printf("31");break; case 4: case 6: case 9: case 11: printf("30");break; case 2: if(x%40&&x%100!=0||x%4000) {printf("29"); }else printf("28");break; } return 0; }

              • 0
                @ 2023-8-13 21:30:05
                #include<stdio.h>
                int main(){
                	int x,y ;
                	scanf("%d%d",&x,&y);
                		if(y==1||y==3||y==5||y==7||y==8||y==10||y==12){
                	printf("31");
                		}
                		else
                		if(y==6||y==4||y==9||y==11)
                		{printf("30");
                		}
                		else
                		if(y==2)
                		{
                			if((x%400==0)||(x%4==0&&x%100!=0)){
                			printf("29");	
                			}
                			else{
                				printf("28");
                			}}return 0;
                		}
                
                • 0
                  @ 2022-10-7 18:05:37
                  #include<stdio.h>
                  int main(){
                  	int x,y ;
                  	scanf("%d%d",&x,&y);
                  		if(y==1||y==3||y==5||y==7||y==8||y==10||y==12){
                  	printf("31");
                  		}
                  		else
                  		if(y==6||y==4||y==9||y==11)
                  		{printf("30");
                  		}
                  		else
                  		if(y==2)
                  		{
                  			if((x%400==0)||(x%4==0&&x%100!=0)){
                  			printf("29");	
                  			}
                  			else{
                  				printf("28");
                  			}}return 0;
                  		}
                  
                  • 1

                  信息

                  ID
                  43
                  时间
                  1000ms
                  内存
                  256MiB
                  难度
                  6
                  标签
                  递交数
                  4495
                  已通过
                  1222
                  上传者