1 solutions

  • 0
    @ 2025-11-5 20:07:58

    C++ :

    #include<iostream>
    using namespace std;
    int main()
    {
    	int year,month;
    	cin>>year>>month;
    	switch(month)
    	{
    		case 1:
    		case 3:
    		case 5:
    		case 7:
    		case 8:
    		case 10:
    		case 12:cout<<31<<endl;break;
    		case 4:
    		case 6:
    		case 9:
    		case 11:cout<<30<<endl;break;
    		case 2: if((year%4==0 && year%100!=0) || year%400==0) 
    		{
    			cout<<29<<endl;break;
    		}
    		else
    		{
    			cout<<28<<endl;break;
    		} 
    	}
    	return 0;
    }
    

    Pascal :

    var month,year:integer;b:boolean;
    begin
      readln(year,month);
      b:=false;
      if (year mod 4=0)and(year mod 100<>0)or(year mod 400=0) then b:=true;
      case month of
        1,3,5,7,8,10,12:writeln(31);
    	4,6,9,11:writeln(30);
    	2:if b then writeln(29)else writeln(28);
      end;
    end.
    
    • 1

    Information

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