1 条题解

  • 0
    @ 2025-10-10 19:52:16

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    int a,b,c,t,s;
    char d;
    int main()
    {
    	cin>>a>>d>>b>>d>>c;
    	if(a%100==0)
    	{
    		if(a%400==0)
    		t=29;
    		else
    		t=28;
    	}
    	else 
    	{
    		if(a%4==0)
    		t=29;
    		else
    		t=28;
    	}
    	int f[12]{31,t,31,30,31,30,31,31,30,31,30,31};
    	for(int i=0;i<b-1;i++)
    	s+=f[i];
    	cout<<s+c;
       return 0;
    }
    
    

    Pascal :

    program t14044;
    const day:array [1..12] of longint=(31,28,31,30,31,30,31,31,30,31,30,31);
    var
      st,ch1,ch2,ch3:string;
      y,m,d,len,p,max,i:longint;
      c:integer;
    begin
      readln(st);
      len:=length(st);
    
      p:=pos('-',st);
      ch1:=copy(st,1,p-1);
      val(ch1,y,c);
    
      delete(st,1,p);
      p:=pos('-',st);
      ch2:=copy(st,1,p-1);
      val(ch2,m,c);
    
      ch3:=copy(st,p+1,len);
      val(ch3,d,c);
    
      for i:=1 to m-1 do
        begin
          if i<>2 then max:=max+day[i] else
          if (y mod 4=0) and (y mod 100<>0) or (y mod 400=0) then max:=max+29
          else max:=max+28;
        end;
      max:=max+d;
      writeln(max);
    end.
    
    • 1

    信息

    ID
    1065
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者