讨论 / 程序
ljx1106 2013-10-29 06:47:00
点我顶贴 收藏 删除
program bi4

type

arr=array[1..6] of integer

var

st :string

sa :string

flag :boolean

s1,s2 :string

fuzhi :integer

ss :array[1..6] of string

i,j,k,tot,l :integer

c :array[1..6] of integer

d :array[1..6] of integer

f :array[1..6] of integer

function check(x:integerg:arr):integer

var

k :integer

h :array [1..6] of integer

begin

for i :=1 to 6 do

h[i] :=g[i]

case x of

3 : begin case h[x-1] of

1,3,5,7,8,10,12 :check :=31

4,6,9,11 :check :=30

2 :if (h[x-2] mod 4=0) and (h[x-2] mod 100<>0) or (h[x-2] mod 400=0) then check :=29 else check :=28

end

end

2 :begin check :=12 end

4 :begin check :=24 end

5 :begin check :=60 end

6 :begin check :=60 end

end

end

begin

assign(input,bi4.in)

reset(input)

assign(output,bi4.out)

rewrite(output)

readln(st)

l :=length(st)

i :=0

tot :=0

repeat

inc(i)

case st[i] of

0..9: begin inc(tot) c[tot] :=ord(st[i])-48 inc(i) while (st[i] <>/) and (i<=l) do

begin

c[tot] :=c[tot]*10+ord(st[i])-48 inc(i)

end

i :=i-1

end

end

until i=l+1

d[1] :=1990 d[2] :=5 d[3] :=18 d[4] :=10 d[5] :=20 d[6] :=1

flag :=false

for i :=1 to 6 do

begin

if c[i]>d[i] then begin flag :=true break end else begin flag :=falsebreakend

end

if flag then

begin

k :=6

repeat

if c[k]<d[k] then begin fuzhi :=check(k,c) c[k] :=c[k]+fuzhi c[k-1] :=c[k-1]-1 end

f[k] :=c[k]-d[k]

k :=k-1

until k=0

end

if not flag then

begin

k :=6

repeat

if d[k]<c[k] then begin fuzhi :=check(k,d) d[k] :=d[k]+fuzhi d[k-1] :=d[k-1]-1 end

f[k] :=d[k]-c[k]

k :=k-1

until k=0

end

for i :=1 to 5 do

write(f[i],/)

write(f[6])

writeln

close(input)

close(output)

end.

#1 falood@2007-09-17 02:38:00
回复 删除
这个是标程吗
#2 lizhixin@2008-07-08 20:45:00
回复 删除
program N0_75;

const y:array[1..12]of longint=(31,59,90,121,152,182,213,244,274,305,336,365);

var s:string;

i,ni,year,month,day,hour,min,second,j:longint;

w,n,w1,w2:int64;

function run(k:longint):boolean;

begin

run:=false;

if (k mod 4=0) and (k mod 100<>0) then run:=true;

if k mod 400=0 then run:=true;

end;

begin

w:=0;

readln(s);

i:=pos(/,s);

val(copy(s,1,i-1),n);

delete(s,1,i);

for i:=1 to n do

begin

w:=w+31536000;

if run(i-1) then w:=w+24*3600;

end;

ni:=n;

i:=pos(/,s);

val(copy(s,1,i-1),n);

delete(s,1,i);

if (n>2) and run(ni) then w:=w+24*3600;

w:=w+y[n-1]*24*3600;

i:=pos(/,s);

val(copy(s,1,i-1),n);

delete(s,1,i);

w:=w+n*24*3600;

i:=pos(/,s);

val(copy(s,1,i-1),n);

delete(s,1,i);

w:=w+n*3600;

i:=pos(/,s);

val(copy(s,1,i-1),n);

delete(s,1,i);

w:=w+n*60;

val(s,n);

w:=w+n;

w:=abs(w-62810418000);

second:=w mod 60;

w:=w div 60;

min:=w mod 60;

w:=w div 60;

day:=w mod 24;

w:=w div 24;

if ni>1990 then ni:=1990;

w2:=0;

if run(ni) then w1:=366 else w1:=365;

j:=ni;

while w1<=w do

begin

inc(j);

w2:=w1;

w1:=w1+365;

if run(j) then inc(w1);

end;

year:=j-ni;

w:=w-w2;

w2:=0;

w1:=31;

j:=0;

while w1<=w do

begin

inc(j);

w2:=w1;

w1:=y[j];

if (j=3) and run(year+ni) then inc(w1);

end;

month:=j;

day:=w-w2;

writeln(year,/,month,/,day,/,hour,/,min,/,second);

readln

end.

@#%@$%$#^#$

本题我放弃还不行吗.....

#3 yumaosheng@2013-10-29 06:47:00
回复 删除
正解```

俺的程序,可以参考参考!!

const

b:array[1..6] of integer=(1990,5,18,10,20,0);

j:array[1..6] of integer=(1,12,30,24,60,60);

var

a:array[1..6] of integer;

i,k,f:integer;

st:string;

begin

read(st);

k:=1;

for i:=1 to 5 do

begin

val(copy(st,1,pos('/',st)-1),a[i]);

delete(st,1,pos('/',st));

if a[i]<b[i] then k:=-1;

end;

val(st,a[6]);

if a[6]<b[6] then k:=-1;

for i:=1 to 6 do

begin

f:=k*(a[i]-b[i]);

if f<0 then

begin

f:=f+j[i];

a[i-1]:=a[i-1]-1;

end;

a[i]:=f;

end;

for i:=1 to 5 do write(a[i],'/');

writeln(a[6]);

end.

查看更多回复
提交回复