|
pascal版的。- program Hashmat;
- var a,b:int64;
- begin
- while not eof do
- begin
- readln(a,b);
- writeln(abs(a-b))
- end
- end.
复制代码-
- program Physics;
- var v,t:integer;
- begin
- while not eof do
- begin
- readln(v,t);
- writeln(2*v*t)
- end
- end.
复制代码- program EcologicalPremium;
- var n,f,i,j:integer;
- a,b,c,s:int64;
- begin
- readln(n);
- for i:=1 to n do begin
- readln(f);
- s:=0;
- for j:=1 to f do begin
- readln(a,b,c);
- s:=s+a*c;
- end;
- writeln(s)
- end
- end.
复制代码- program Decoder;
- var s:string;
- a:integer;
- begin
- while not eof do
- begin
- readln(s);
- for a:=1 to length(s) do
- write(chr((ord(s[a])-7) mod 256));
- writeln
- end
- end.
复制代码- program Counting;
- var s:string;
- b:boolean;
- i,t:integer;
- begin
- while not eof do
- begin
- readln(s);
- t:=0;b:=false;
- for i:=1 to length(s) do
- if ((65<=ord(s))and(ord(s)<=90)) or
- ((97<=ord(s))and(ord(s)<=122)) then
- begin
- if b=false then t:=t+1;
- b:=true
- end
- else
- b:=false;
- writeln(t)
- end
- end.
复制代码- program Surface;
- var sum,min,t:integer;
- i,j,n:integer;
- s:string;
- begin
- repeat
- sum:=0;
- min:=25;
- readln(n);
- for i:=1 to n do begin
- t:=0;
- readln(s);
- for j:=1 to length(s) do
- if s[j]=' ' then inc(t);
- sum:=sum+t;
- if t<min then min:=t
- end;
- if n<>0 then writeln(sum-n*min)
- until n=0;
- end.
复制代码- program Rotate;
- var c:array[1..100,1..100] of char;
- i,j,m,n:integer;
- max:integer;
- s:string;
- begin
- m:=0;
- n:=0;
- fillchar(c,sizeof(c),' ');
- while not eof do
- begin
- readln(s);
- inc(n);
- j:=length(s);
- if j>m then m:=j;
- for i:=1 to j do c[i,n]:=s;
- end;
- for i:=1 to m do begin
- for j:=1 to n do
- write(c[i,n+1-j]);
- writeln
- end
- end.
复制代码- program Maze;
- var s:string;
- c:char;
- i,j,n:integer;
- begin
- while not eof do
- begin
- readln(s);
- n:=0;
- for i:=1 to length(s) do begin
- c:=s;
- if c='b' then c:=' ';
- if (48<=ord(c)) and (ord(c)<=57) then
- n:=n+ord(c)-48
- else begin
- for j:=1 to n do write(c);
- n:=0;
- end;
- if c='!' then writeln
- end;
- writeln
- end
- end.
复制代码- program Wave;
- var n,nc,h,f,i,j,k:longint;b:boolean;
- begin
- read(n);
- b:=false;
- for nc:=1 to n do begin
- read(h,f);
- if h*f<>0 then begin
- if b then begin writeln;writeln end;
- for i:=1 to f do begin
- if i>1 then begin writeln;writeln end;
- for j:=1 to h do begin
- for k:=1 to j do write(j);
- if h<>1 then writeln
- end;
- for j:=h-1 downto 1 do begin
- for k:=1 to j do write(j);
- if j<>1 then writeln
- end;
- end;
- b:=true;
- end;
- end;
- writeln;
- close(output)
- end.
复制代码- program Hangman;
- // O
- // /|\
- // |
- // /\
- var guess,ans:array[1..26] of boolean;
- stock,sum:longint;
- round,i,t:longint;
- guesss,anss:string;
- label 1;
- begin
- while true do begin
- 1: readln(round); if round=-1 then halt; writeln('Round ',round);
- readln(anss); readln(guesss);
- if anss='' then begin writeln('You win.'); goto 1 end;
- if guesss='' then begin writeln('You chickened out.'); goto 1 end;
- for i:=1 to 26 do begin guess:=false; ans:=false end; sum:=0; stock:=0;
- for i:=1 to length(anss) do if ans[ord(anss)-96]=false then begin inc(sum); ans[ord(anss)-96]:=true end;
- for i:=1 to length(guesss) do if guess[ord(guesss)-96]=false then begin
- if ans[ord(guesss)-96]=true then dec(sum) else inc(stock);
- guess[ord(guesss)-96]:=true;
- if sum=0 then begin writeln('You win.'); break end;
- if stock=7 then begin writeln('You lose.'); break end
- end;
- if (sum<>0) and (stock<>7) then writeln('You chickened out.');
- end;
- end.
复制代码- program Collatz;
- var a,lim,num,i:int64;
- begin
- i:=0;
- while true do begin
- readln(a,lim);if(a<0)and(lim<0)then halt;
- num:=0;inc(i);write('Case ',i,': A = ',a,', limit = ',lim,', number of terms = ');
- while(a<=lim)and(a<>1)do begin
- if odd(a) then a:=3*a+1 else a:=a div 2;inc(num) end;
- if a=1 then inc(num);
- writeln(num);
- end;
- end.
复制代码- Program Cell;
- var a:array[0..41] of longint;
- b:array[1..40] of longint;
- dna:array[0..9] of longint;
- n,nc,c,i,m,k:longint;
- ch:char;
- begin
- read(n);
- for nc:=1 to n do begin
- for i:=0 to 9 do read(dna);
- for i:=0 to 41 do a:=0;
- a[20]:=1;
- for i:=1 to 19 do write(' ');
- write('.');
- for i:=21 to 40 do write(' ');
- writeln;
- for c:=2 to 50 do begin
- for i:=1 to 40 do
- b:=dna[a[i-1]+a+a[i+1]];
- for i:=1 to 40 do begin
- a:=b;
- ch:=' ';
- if a=0 then ch:=' ';
- if a=1 then ch:='.';
- if a=2 then ch:='x';
- if a=3 then ch:='W';
- write(ch);
- end;
- writeln;
- end;
- if nc<>n then writeln;
- end;
- end.
复制代码 |
|