Sie sind auf Seite 1von 20

1) var nr,S:string[9];

i:char;
y,n:longint;
err:integer;
begin
write ('n=');
readln (n);
nr:='';
str (n,S);
for i:='9' downto '0' do
if pos (i,S)<>0 then
nr:=nr+i;
val (nr,y,err);
writeln ('Numarul este: ',y);
end.

2) var d,n:integer;
sw,sw1:byte;
begin
write ('n=');
readln (n);
sw:=0;
while (n>0) and (sw=0) do
begin
sw1:=0;
for d:=2 to n div 2 do
if n mod d = 0 then
sw1:=1;
if sw1=1 then
sw:=1;
n:=n div 10;
if sw=0 then
writeln ('superprim')
else
writeln ('0');
end;
end.

3) var p,nr,uc:word;
n:longint;
begin
write ('n=');
readln (n);
nr:=0;
p:=1;
repeat
uc:=n mod 10;
n:=n div 10;
if uc mod 2 = 1 then
begin
nr:=uc*p + nr;
p:=p*10;
end;
until n=0;
writeln (nr);
end.

4) var i,j,n,d:word;
sw:byte;
begin
write ('n=');
readln (n);
i:=1;
repeat
inc(i);
sw:=0;
for d:=2 to i div 2 do
if i mod d=0 then
sw:=1;
if sw=0 then
if sqr(i)<=n then
write(sqr(i),' ');
until sqr(i)>n;
end.

5) var n:integer;
i,x,h,ogl:word;
begin
write ('n=');
readln (n);
i:=n;
repeat
inc(i);
ogl:=0;
x:=i;
repeat
h:=x mod 10;
ogl:=ogl*10 + h;
x:=x div 10;
until x=0;
until ogl=i;
writeln (i);
end.

6) var p,x,k:word;
n:integer;

begin
write ('n=');
readln (n);
write ('k=');
readln (k);
p:=1;
x:=n;
repeat
p:=p*10;
x:=x div 10;
until x<10;
while (k>0) and (n>0) do
begin
n:=n mod p;
p:=p div 10;
dec(k);
end;
if n=0 then
writeln ('vid')
else
writeln (n);
end.

7) var n:integer;
sw,sw1,i,j:byte;
x,S:word;

begin
write ('n=');
readln (n);
sw:=0;
for i:=1 to n do
begin
write ('x=');
readln (x);
S:=1+x;
for j:=2 to x div 2 do
if x mod j = 0 then
S:=S+j;
sw1:=0;
for j:=2 to S div 2 do
if S mod j = 0 then
sw1:=1;
if sw1=0 then
begin
write (x);
sw:=1;
end;
end;
if sw=0 then
write ('niciun numar');
end.

8) var i,n,sw:byte;
x:word;
d,S:longint;
begin
write ('n=');
readln (n);
S:=0;
d:=2;
sw:=0;
for i:=1 to n do
begin
write ('x=');
readln (x);
S:=S+x;
end;
repeat
if S mod d=0 then
begin
sw:=1;
d:=d+1;
end;
until (sw=1) or (d=S div 2);
if sw=0 then
write ('da')
else
writeln ('nu');
end.

9) var S,x:word;
n,i:byte;
begin
write ('n=');
readln (n);
S:=0;
for i:=1 to n do
begin
write ('x=');
readln (x);
S:=(S + x mod 10) mod 10;
end;
write ('S=');
writeln (S);
end.

10) var S:string[20];


n:word;
sw,i,d,cont:byte;
x:integer;
begin
write ('n=');
readln (n);
cont:=0;
for i:=1 to n do
begin
write ('x=');
readln (x);
d:=2;
sw:=0;
repeat
if x mod d = 0 then
sw:=1;
inc(d);
until (sw=1) or (d=x div 2);
if sw=0 then
begin
str(x,S);
inc(cont,length (S));
end;
end;
write (cont);
end.

11) var V:array [1..100] of integer;


ma,i,n,x:word;
nr:byte;
S:longint;
begin
write ('n=');
readln (n);
S:=0;
nr:=0;
for i:=1 to n do
begin
readln (V[i]);
S:=S+V[i];
end;
ma:=S div n;
for i:=1 to n do
if V[i]>=ma then
inc(nr);
writeln (nr);
end.

12) var V:array [1..100] of integer;


i,sw:byte;
n,max,S:integer;

begin
write ('n=');
readln (n);
S:=0;
max:=-maxint;
sw:=0;
for i:=1 to n do
begin
readln (V[i]);
if V[i]>=0 then
begin
inc(S,V[i]);
sw:=1;
end
else
if V[i]>max then
max:=V[i];
end;
if sw=1 then
write (S)
else
write (max);
end.

13) var A,B:array [1..100] of integer;


i,m,n:byte;
cont,min:integer;

begin
writeln ('n=');
readln (n);
write ('m=');
readln (m);
min:=maxint;
for i:=1 to m do
begin
write ('B[',i,']=');
readln (B[i]);
if min>B[i] then
min:=B[i];
end;
cont:=0;
for i:=1 to n do
begin
write ('A[',i,']=');
readln (A[i]);
if A[i]<min then
inc(cont);
end;
write (cont);
end.

14) var V:array [1..100] of integer;


aux,n,sw,i:word;
x:integer;
begin
write ('n=');
readln (n);
for i:=1 to n do
begin
readln (x);
while x>9 do
begin
x:=x div 10;
V[i]:=x;
end;
end;
repeat
sw:=0;
for i:=1 to n-1 do
if V[i]<V[i+1] then
begin
aux:=V[i];
V[i]:=V[i+1];
V[i+1]:=aux;
sw:=1;
end;
until sw=0;
for i:=1 to n do
write (V[i]);
end.

15) var s,f,n,nr,sol,i,p,y,x,mij:longint;

begin
write ('n=');
readln (n);
nr:=1;
x:=n;
while x>9 do
begin
inc(nr);
x:=x div 10;
end;
p:=1;
for i:=1 to nr div 2 do
p:=p*10;
s:=n mod p;
if nr mod 2 = 0 then
f:=n div p
else
begin
f:=n div p;
mij:=f mod 10;
f:=f div 10;
sol:=(s*10+mij)*p+f;
end;
if nr mod 2 = 0 then
sol:=s*p + f;
writeln (sol);
readln;
end.

16) var V:array [1..100] of integer;


n,i:integer;
aux,sw:byte;

begin
write ('n=');
readln (n);
for i:=1 to n do
begin
write ('V[',i,']=');
readln (V[i]);
end;
repeat
sw:=0;
for i:=1 to n-2 do
begin
if i mod 2=1 then
if V[i]<V[i+2] then
begin
aux:=V[i+2];
V[i+2]:=V[i];
V[i]:=aux;
sw:=1;
end;
if i mod 2 = 0 then
if V[i]>V[i+2] then
begin
aux:=V[i+2];
V[i+2]:=V[i];
V[i]:=aux;
sw:=1;
end;
end;
until sw=0;
for i:=1 to n do
writeln (V[i]);
end.

17) var A:array [1..10,1..10] of byte;


n,i,j:byte;

begin
write ('n=');
readln (n);
for i:=1 to n do
for j:=1 to n do
A[i,j]:=2;
for i:=1 to n do
begin
A[i,i]:=1;
A[i,n-i+1]:=1;
end;
for i:=1 to n do
begin
for j:=1 to n do
write (A[i,j],'');
writeln;
end;
end.

18) var f:text;


nr,l,i,n:byte;
begin
write ('n=');
readln (n);
assign (f,'piramida.txt');
rewrite (f);
l:=1;
nr:=0;
for i:=1 to n do
if nr=l then
begin
writeln (f,i);
nr:=0;
l:=l+1;
end
else
begin
write (f,i,' ');
inc(nr);
end;
close(f);
end.

19) var A:array [1..10,1..10] of integer;


n,i,j:byte;
S:integer;
begin
write ('n=');
readln (n);
for i:=1 to n do
for j:=1 to n do
begin
write (A[i,j],' ');
readln (A[i,j]);
end;
for i:=1 to n do
for j:=1 to i do
S:=S+A[i,j];
writeln (S);
end.

20) var A,B:array [1..400] of integer;


V:array [1..20,1..20] of integer;
n,i,j,k,t:word;
sw:byte;
max:integer;

begin
write ('n=');
readln (n);
k:=0;
for i:=1 to n do
for j:=1 to n do
readln (V[i,j]);
for i:=1 to n do
for j:=1 to n do
begin
if k=0 then
begin
inc(k);
A[k]:=V[i,j];
B[i]:=1;
end
else
sw:=0;
for t:=1 to k do
if A[t]=V[i,j] then
begin
inc(B[t]);
sw:=1;
end;
if sw=0 then
begin
inc(k);
A[k]:=V[i,j];
B[k]:=1;
end;
end;
sw:=B[1];
for i:=2 to k do
if B[i]>max then
max:=B[i];
for i:=1 to k do
if B[i]=max then
writeln (A[i],' ');
end.

21) var n:integer;


V:array [1..20] of integer;
i,j,sw:byte;

begin
write ('n=');
readln (n);
for i:=1 to n do
readln (V[i]);
sw:=0;
for i:=1 to n do
for j:=i+1 to n do
if V[i]=V[j] then
sw:=1;
if sw=1 then
writeln ('NU')
else
writeln ('DA');
end.

22) var A:array [1..10,1..10] of word;


m,n,j,i:byte;
max,min:integer;

begin
write ('m=');
readln (m);
write ('n=');
readln (n);
for i:=1 to m do
for j:=1 to n do
begin
write ('A[',i,',',j,']=');
readln (A[i,j]);
end;
max:=0;
for i:=1 to m do
begin
min:=A[i,1];
for j:=1 to n do
if A[i,j]<min then
min:=A[i,j];
write (min,' ');
if max<min then
max:=min;
end;
writeln ('max= ',max);
end.

23) var A:array [1..10,1..10] of byte;


x:longint;
n,i,j:byte;
begin
write ('n=');
readln (n);
write ('x=');
readln (x);
for i:=1 to n do
begin
for j:=1 to n do
A[i,j]:=x mod 10;
x:=x div 10;
end;
for i:=1 to n do
begin
for j:=1 to n do
write (A[i,j],' ');
writeln;
end;
end.

24) var A:array [1..30,1..30] of integer;


sw,t,m,n,i,j,min:byte;
p:word;
begin
write ('n=');
readln (n);
for i:=1 to n do
for j:=1 to n do
begin
write ('A[',i,',',j,']=');
readln (A[i,j]);
end;
sw:=0;
p:=1;
for i:=1 to n do
begin
min:=100;
for t:=1 to n do
if A[t,n-i+1]<min then
min:=A[t,n-i+1];
if A[i,n-i+1]=min then
begin
p:=p*min;
sw:=1;
end;
end;
if sw=1 then
writeln (p)
else
write ('nu exista');
end.

25) var V:array [1..20,1..20] of longint;


i,j,n:byte;
x,S,S1:integer;
begin
write ('n=');
readln (n);
for i:=1 to n do
for j:=1 to n do
begin
write ('V[',i,',',j,']=');
readln (V[i,j]);
end;
S:=0;
S1:=0;
for i:=1 to n do
begin
inc(S,V[i,i]);
inc(S1,V[i,n-i+1]);
end;
x:=S-S1;
writeln ('x= ',x);
end.

26) var A:array [1..10,1..10] of integer;


m,n,i,j,p1,p2,p3,p4:byte;
min,max,aux:integer;
begin
write ('m=');
readln (m);
write ('n=');
readln (n);
for i:=1 to m do
for j:=1 to n do
begin
write ('A[',i,',',j,']=');
readln (A[i,j]);
end;
p1:=0;
p2:=0;
p3:=0;
p4:=0;
min:=maxint;
max:=-maxint;
for i:=1 to m do
for j:=1 to n do
begin
if A[i,j]<min then
begin
min:=A[i,j];
p1:=i;
p2:=j;
end;
if A[i,j]>max then
begin
max:=A[i,j];
p3:=i;
p4:=j;
end;
end;
aux:=A[p1,p2];
A[p1,p2]:=A[p3,p4];
A[p3,p4]:=aux;
for i:=1 to m do
begin
for j:=1 to n do
write (A[i,j],' ');
writeln;
end;
end.

27) var f:text;


n,i,j,k,cont,cont1,sw:word;
A:array [1..10,1..10] of integer;

begin
assign (f,'f1.in');
reset (f);
readln (f,n);
for i:=1 to n do
begin
for j:=1 to n do
begin
read(f,A[i,j]);
write(A[i,j],' ');
end;
readln(f);
writeln;
end;
cont:=0;
cont1:=0;
for i:=1 to n-1 do
for j:=i+1 to n do
if (sqrt(A[i,j]) = trunc(sqrt(A[i,j]))) then
inc(cont);
for i:=2 to n do
for j:=1 to i-1 do
begin
sw:=0;
k:=2;
while (k<=sqrt(A[i,j])) do
begin
if (A[i,j] mod k = 0) then
sw:=1;
inc(k);
end;
if sw=0 then
inc(cont1);
end;
writeln (cont,' ',cont1);
close(f);
end.

28) var A:array [1..10,1..10] of integer;


i,j,n:byte;

begin
write ('n=');
readln (n);
for i:=1 to n do
for j:=1 to n do
A[i,j]:=2;
for i:=1 to n do
begin
A[i,i]:=0;
A[i,n-i+1]:=0;
end;
for i:=1 to n div 2 do
for j:=i+1 to n-i do
begin
A[i,j]:=1;
A[n-i+1,j]:=1;
end;
for i:=1 to n do
begin
for j:=1 to n do
write (A[i,j],' ');
writeln;
end;
end.

29) var f:text;


dp,ds,x:word;
i,n,j:byte;
a:array[1..10,1..10] of integer;
begin
assign (f,'f.in');
reset (f);
readln (f,n);
dp:=0;
ds:=0;
for i:=1 to n do
for j:=1 to n do
read(f,a[i,j]);
for i:=1 to n do
begin
inc(dp,a[i,i]);
inc(ds,a[i,n-i+1]);
end;
close(f);
write (dp,' ',ds);
end.

30) var V:array [1..20,1..20] of integer;


i,j,n,m,cont:integer;
max:longint;
begin
write ('n=');
readln (n);
write ('m=');
readln (m);
for i:=1 to n do
for j:=1 to m do
begin
write ('V[',i,',',j,']=');
readln (V[i,j]);
end;
max:=-maxint;
cont:=0;
for j:=1 to m do
begin
if V[1,j]>max then
begin
max:=V[1,j];
cont:=1;
end
else
if V[1,j]=max then
inc(cont);
if V[n,j]>max then
begin
max:=V[n,j];
cont:=1;
end
else
if V[n,j]=max then
inc(cont);
end;
for i:=2 to n-1 do
begin
if V[i,1]>max then
begin
max:=V[i,1];
cont:=1;
end
else
if V[i,1]=max then
inc(cont);
if V[i,m]>max then
begin
max:=V[i,m];
cont:=1;
end
else
if V[i,m]=max then
inc(cont);
end;
write (max,' ',cont);
end.

31) var A:array [1..20,1..20] of word;


i,j,n:byte;
begin
write('n=');
readln(n);
A[1,1]:=1;
A[1,2]:=1;
for j:=3 to n do
A[1,j]:=A[1,j-1]+A[1,j-2];
for i:=2 to n do
begin
A[i,1]:=A[i-1,n-1]+A[i-1,n];
A[i,2]:=A[i,1]+A[i-1,n];
for j:=3 to n do
A[i,j]:=A[i,j-1]+A[i,j-2];
end;
for i:=1 to n do
begin
for j:=1 to n do
write (A[i,j],' ');
writeln;
end;
end.

32) var V,V1:array [1..100] of string[10];


V2:array [1..100] of byte;
i,j,t,sw,n:byte;
x,aux:string[10];
begin
write ('n= ');
readln (n);
for i:=1 to n do
begin
readln (V[i]);
x:=V[i];
for j:=1 to length(x) do
x[j]:=upcase(x[j]);
V1[i]:=x;
V2[i]:=i;
end;
repeat
sw:=0;
for i:=1 to n-1 do
if V1[i]>V1[i+1] then
begin
aux:=V1[i];
V1[i]:=V1[i+1];
V1[i+1]:=aux;
t:=V2[i];
V2[i]:=V2[i+1];
V2[i+1]:=t;
sw:=1;
end;
until sw=0;
for i:=1 to n do
writeln (V[V2[i]]);
end.

33) var S1,S2:string[20];


i,h:byte;
begin
readln(S1);
readln(S2);
for i:=1 to length(S1) do
begin
h:=pos(S1[i],S2);
if h<>0 then
delete(S2,h,1);
end;
if S2='' then
writeln ('DA')
else
writeln ('NU');
end.

34) var f:text;


cont,i,n:longint;
x,max:byte;
begin
assign (f,'numere.txt');
reset (f);
max:=0;
cont:=0;
readln (f,n);
for i:=1 to n do
begin
read (f,x);
if x>max then
begin
max:=x;
cont:=1;
end
else
if x=max then
inc (cont);
end;
close(f);
writeln (max,' ',cont);
end.

35) var S:string[20];


i:byte;
begin
readln (S);
i:=1;
repeat
if (S[i]>='a') and (S[i]<='z') then
delete (S,i,1)
else
inc(i);
until i>length(S);
writeln (S);
end.

36) var V:array[1..250] of word;


x,opt:char;
i,max:word;
begin
for i:=ord('0') to ord('9') do
V[i]:=0;
repeat
writeln ('Continuati? (D/N)');
readln (opt);
if opt='D' then
begin
readln (x);
if (x>='0') and (x<='9') then
inc (V[ord(x)]);
end;
until opt='N';
max:=0;
for i:=ord('0') to ord('9') do
if V[i]>max then
max:=V[i];
i:=ord('0');
while V[i]<>max do
inc(i);
write (chr(i),' ',max);
end.
37) var S:string[25];
i,n,p,j,sw:byte;
begin
write ('n=');
readln (n);
for i:=1 to n do
begin
write ('S=');
readln (S);
sw:=0;
p:=length(S);
for j:=1 to (p div 2) do
if S[j]<>S[p-j+1] then
sw:=1;
if sw=0 then
writeln (S);
end;
end.

38) var f,g:text;


i:word;
x:char;
begin
assign (f,'unu.txt');
assign (g,'doi.txt');
reset (f);
rewrite (g);
i:=1;
while not eof(f) do
begin
if i mod 2 = 1 then
begin
while not eoln(f) do
begin
read (f,x);
write (g,x);
end;
writeln (g);
end;
readln (f);
inc(i);
end;
close (f);
close (g);
end.

39) var S:string[250];


M:set of char;
i,cont:byte;
begin
M:=['.',',',':',';','?','!','-'];
read (S);
cont:=0;
for i:=1 to length(S) do
if S[i] in M then
inc (cont);
write (cont);
end.

40) var t,S:string[250];


f:text;
max:byte;
begin
assign (f,'poezie.in');
reset (f);
max:=0;
t:='';
while not eof (f) do
begin
readln (f,S);
if length(S)>max then
begin
max:=length(S);
t:=S;
end;
end;
close(f);
writeln(t);
end.

Das könnte Ihnen auch gefallen