Created
February 8, 2009 11:30
-
-
Save zlw/60351 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program sprawdzian; | |
uses Crt; | |
var | |
a,a1,a2:array[1..10] of byte; | |
i,x,j:integer; | |
procedure array_init; | |
begin | |
writeln('Podaj ', i, ' liczbe tablicy a1'); | |
readln(a1[i]); | |
writeln('Podaj ', i, ' liczbe tablicy a2'); | |
readln(a2[i]); | |
end; | |
procedure array_sort; | |
begin | |
for i:=2 to 10 do | |
begin | |
x:=a[i]; | |
a[i]:=x; | |
j:=i-1; | |
while x<a[j] do | |
begin | |
a[j+1]:= a[j]; | |
inc(j,-1); | |
end; | |
a[j+1]:=x; | |
end; | |
j:=0; | |
x:=0; | |
end; | |
function dec2bin(d:longint):string; | |
var r,s:string; | |
begin | |
r:=''; | |
if d<>0 then | |
while d<>0 do | |
begin | |
str(d mod 2,s); | |
r:=s+r; | |
d:=d div 2; | |
end | |
else | |
r:='0'; | |
dec2bin:=r; | |
end; | |
begin | |
ClrScr; | |
for i:=1 to 10 do | |
begin | |
array_init; | |
end; | |
writeln(); | |
writeln('Tablice a1 i a2:'); | |
for i:=1 to 10 do | |
begin | |
writeln('a1: ', a1[i], ' a2: ', a2[i]); | |
end; | |
{sortowanie} | |
a:=a1; | |
array_sort; | |
a1:=a; | |
a:=a2; | |
array_sort; | |
a2:=a; | |
writeln(); | |
writeln('Posortowane tablice a1 i a2'); | |
for i:=1 to 10 do | |
begin | |
writeln('a1: ', a1[i], ' a2: ', a2[i]); | |
end; | |
{dec2bin} | |
writeln(); | |
writeln('Posortowane tablice a1 i a2 w zapisie binarnym'); | |
for i:=1 to 10 do | |
begin | |
writeln('a1: ', dec2bin(a1[i]), ' a2: ', dec2bin(a2[i])); | |
end; | |
{chr} | |
writeln(); | |
writeln('Znaki ASCII odpowiadające elementom tablic a1 i a2'); | |
for i:=1 to 10 do | |
begin | |
writeln('a1: ', chr(a1[i]), ' a2: ', chr(a2[i])); | |
end; | |
readln; | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment