theninc(t2);
ift1=t2
theninc(sum);
end;
writeln(sum);
close(input);
close(output);
end.
8.纯粹化信息
vara:
array['A'..'Z']ofboolean;
s:
string;
i:
longint;
temp:
char;
PD:
BOOLEAN;
begin
assign(input,'krunch.in');reset(input);
assign(output,'krunch.out');rewrite(output);
fillchar(a,sizeof(a),true);
A['A']:
=FALSE;
A['E']:
=FALSE;
A['I']:
=FALSE;
A['O']:
=FALSE;
A['U']:
=FALSE;
s:
='';
whilenot(eoln)do
begin
read(temp);
PD:
=((temp='')and(temp<>s[length(s)]))OR((TEMP<>'')AND(temp<>',')and(temp<>'.')and(temp<>'?
')and(A[TEMP]))or((temp=',')or(temp='.')or(temp='?
'));
ifPDthenbegins:
=s+temp;IF(TEMP<>'')and(temp<>'.')and(temp<>'?
')THENa[temp]:
=false;end;
end;
fori:
=1tolength(s)do
if((s[i]=',')or(s[i]='.')or(s[i]='?
'))and(s[i-1]='')thendelete(s,i-1,1);
ifs[1]=''thendelete(s,1,1);
ifs[length(s)]=''thendelete(s,length(s),1);
writeln(s);
close(input);
close(output);
end.
9.打印日历
constmonth:
array[1..12]ofstring[10]
=('Janu','Fabr','Marc','Apri','May','June',
'July','Augu','Sept','Octo','Nove','Dece');
day:
array[0..6]ofstring[10]
=('SUN','MON','TUE','WEN','THU','FRI','SAT');
vari,j,k,y,first:
longint;
ds,ts:
array[1..12]oflongint;
begin
assign(input,'cal.in');
reset(input);
readln(y);
first:
=(y+(y-1)div4-(y-1)div100+(y-1)div400)mod7;
ds[1]:
=31;ds[2]:
=28;ds[3]:
=31;ds[4]:
=30;ds[5]:
=31;ds[6]:
=30;
ds[7]:
=31;ds[8]:
=31;ds[9]:
=30;ds[10]:
=31;ds[11]:
=30;ds[12]:
=31;
if(ymod400=0)or(ymod4=0)and(ymod100<>0)theninc(ds[2]);
ts[1]:
=first;
fori:
=2to12dots[i]:
=ts[i-1]+ds[i-1];
assign(output,'cal.out');
rewrite(output);
write('':
3);
fori:
=1to12dowrite(month[i]:
6);
writeln;
fori:
=1to3do
forj:
=0to6do
begin
write(day[j]);
fork:
=1to12do
begin
if(i-1)*7+j+1-ts[k]mod7>=1
thenwrite((i-1)*7+j+1-ts[k]mod7:
3)
elsewrite('':
3);
if(i+2)*7+j+1-ts[k]mod7<=ds[k]
thenwrite((i+2)*7+j+1-ts[k]mod7:
3)
elsewrite('':
3)
end;
writeln;
end;
close(output)
end.
10.到天宫做客
programheaven;
constday:
array[1..11]oflongint
=(31,29,31,30,31,30,31,31,30,31,30);
vari,j,n,m,d,t,max:
longint;
s:
array[1..367]ofboolean;
begin
assign(input,'heaven.in');
reset(input);
assign(output,'heaven.out');
rewrite(output);
read(n);
fillchar(s,sizeof(s),false);
s[367]:
=true;
fori:
=1tondo
begin
read(m,d);
{writeln(m,'',d);}
t:
=0;
forj:
=1tom-1dot:
=t+day[j];
t:
=t+d;
s[t]:
=true;
end;
t:
=0;max:
=0;
fori:
=1to367do
ifs[i]then
begin
ifi-t-1>maxthenmax:
=i-t-1;
t:
=i
end;
writeln((max*24*60*60+183)div366);
close(input);
close(output);
end.