1 solutions

  • 0
    @ 2025-11-5 20:12:44

    C++ :

    #include <iostream>
    using namespace std;
    int judge(int year)
     {
      if(year%4==0&&year%100!=0||year%400==0)
    	  return 1;
      else
    	  return 0;
    }
    int main()
    {
    	int n,y,a;
    	int r[12]={31,29,31,30,31,30,31,31,30,31,30,31};
    	int p[12]={31,28,31,30,31,30,31,31,30,31,30,31};
    	cin>>n>>y;
    	a=judge(n);
    
    	if(a==1)
    	    cout<<r[y-1]<<endl;
    	else
    		cout<<p[y-1]<<endl;
    	return 0;
    
    }
    
    

    Pascal :

    program t21245;
    var y,m,d:integer;
    begin
     readln(y,m);
     case m of
      1,3,5,7,8,10,12:d:=31;
      4,6,9,11:d:=30;
      2:
      if(y mod 4=0) and (y mod 100<>0)or(y mod 400=0)
        then d:=29 else d:=28;
      end;
     writeln(d);
    end.
    
    • 1

    Information

    ID
    20136
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By