Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 13

Kerkohet te largohet elementi I k-te nga lista e lidhur.

(k nr I plote)
Var
k: integer;
count: integer;
para:^integer;
pas:^integer;
Procedure FshiK(k,L);
p=L; (* koka e listes *)
begin
if L=nil then writeln(“Lista eshte bosh”) //lista boshe
else begin
if (k%2<>0) || if (k=0) then
writeln(“Error input”);
else if (k=1) then
p^.pas=p
end;
count=1;
while (count<>k) and (p^.pas<>nil) do
begin
p=p^.pas;
count=count+1;
end;
if (count=k) then
begin
para = p;
p=p^.pas;
end;
para^.pas := p^.pas;
end;
if k=L.last then
begin
p^.para=NIL;
end;
end;
end;

Kontrollojme disa raste specifike


1. Nese lista eshte bosh.
2. Nese numri I vendosur nuk eshte integer ose 0,pasi nuk mund te
tregojme se cili element eshte I k-ti.
3. k=1, nese duam te heqim elementin e pare.
4. k=L.last nese duam te heqim elementin e fundit.
5. k eshte nje numer I rastesishem.
DETYRE 2
program Search;
var
text:string;
sub_str:string;
begin
text:='Matematika';
sub_str:='tema';
writeln (text);
readln;
end.

writeln ('Enter the string you want to check:');


readln(text);
writeln ('Enter the sub string you want to check:');
readln(sub_str);

Function Pos(SubString : String; S : String) : Byte;

Description
This function will search for the string SubString within the string S. If the sub-string is not
found, then the function would return 0. If on the other hand the sub-string is found, then the
index integer value of the first character of the main string that matches the character of the sub-
string is returned.
Var
S : String;

Begin
S := 'Hey there! How are you?';
Write('The word "How" is found at char index ');
Writeln(Pos('How', S));
If Pos('Why', S) <= 0 Then
Writeln('"Why" is not found.');
End.

Function CopyString(n,m,S1):string
var
S1:string;
sub_str:string;
numOfChars1,numOfChars2,i:integer;
begin
writeln ('Enter the string you want to check:');
readln (S1);
writeln ('Enter the sub string you want to check:');
readln (sub_str);
while m<S1.length
for i=n to m-1 do
S1[i]=
numOfChars1:= Length (S1);
numOfChars2:= Length (sub_str);
if (numOfChars1==numOfChars2) then
i:=1;
while (i< numOfChars1) then
if (text[byte(S1[i])]==sub_str[byte(sub_str[i])] ) then
writeln ('Substring found in your text.');
end.
writeln ('Length of your word:',numOfChars1);

function

program Search;
var

word,sub_str:string;

begin
writeln ('Enter the string you want to check:');
readln(word);
Writeln('The length of the string is ', byte(word[0]));
Write(word[byte(word[0])]);
Write(' is the last character.');
writeln ('Enter the sub string you want to check:');
readln(sub_str);
Writeln('The length of the string is ', byte(sub_str[0]));
Write(sub_str[byte(sub_str[0])]);

end.

Program Example1;
Var
S1:string;
Sub_string:string;
n:integer;
m:integer;
begin
sub_string:=copy(S1,n,m);

writeln ('Enter the string you want to check:');


readln(S1);
writeln ('Enter the position where you want the substring to start:');
readln(n);
writeln ('Enter the length of substring:');
readln(m);
Writeln (sub_string);
end.
Program Example1;
Var
S1:string;
Sub_string:string;
n:integer;
m:integer;
begin
writeln ('Enter the string you want to check:');
readln(S1);
writeln ('Enter the position where you want the substring to start:');
readln(n);
writeln ('Enter the length of substring:');
readln(m);
sub_string:= Copy(S1,n,m);
Writeln (sub_string);
end.

Function Max(L:list):elementtype
Begin
L.max=-10^10;
while i<L.last do
begin
while(i<L.length)
if(L.element[i]>L.max) do
L.element[i]=L.max;
else
i=i+1;
return L.max

Procedure PrintCiftTekList(L:list,Cift:Boolean)
Begin
while(Cift==True)
if (L.element%2==0)
begin
write (L.element[p])
q = NEXT(p, L);
end
Write (L.element[p])

DETYRE 3

Function RendiRrites(L:LIST):LIST;
const
maxlength = 100;
type
LIST = record
element : array[1..maxlength] of integer;
last:integer;
end;
var
hold:element;
L:LIST;
Begin
p=First(L);
while p<>End(L) DO
Begin
if(L.element[p]>L.elemnt[p+1]) // instead of L.element we can use RETRIEVE(p,L)
RETRIEVE (p+1,L)
hold=L.elemnt[p];
L.elemnt[p]=L.elemnt[p+1];
L.elemnt[p+1]=hold;
writeln(L.elemnt[p]);
if(Not L.element[p]>L.elemnt[p+1])
p=Next(p,L);
end;

Procedure ShtoElement(x,List);
begin
if L=nil then ugjet=false
else begin
p=L;
while (p^.el<>y) && (p^.pas<>nil) do
p=p^.pas;
ugjet=(p^.el=y);
y^.pas=x;
end;
end;

L.y=L.y+1;
L.element=x;

Procedure FshiX(x,L);
begin
if L=nil then exist=false; //lista boshe
else begin
while p^.element<>x && p^.pas<>nil do
begin
p=p^.pas;
end;
if (p^.element=x) then
begin
p^.pas=p^.pas^.pas;
end;
end;

type
Struktura=record
element:string;
pas:^Struktura;
end;
List=^Struktura;
pozition=^Struktura;
Var
P,Q,R:=^Struktura;
begin

L.^pas=p;
New(L.element);
p=q;

Type
tipqelize := record
element: integer;
pas : ^ tipqelize;
end;
Var
shuma:integer;
L : ^tipqelize;
begin
New(L);
L^.pas=5;
L^.pas.pas=2;
L
while L^.pas<>NIL do
beging
shuma=0;
if RETRIVE(p,L)mod 2=1 then
shuma=shuma+RETRIVE(p,L);
else L=L^.pas;
print shuma;
end

Procedure Fshij_Perseritje(L:List)
p=First(el);
while p^.pas<> NIL do
begin
if p=el.data then
p^.pas=p^.pas^.pas;
else
p=p^.pas;

while(p^.el<>p.el.data)

function Gjatesia(L):integer;
begin
q=L;
if q^.pas=Nil; {lista bosh}
return(L); {lista bosh}
else return count(L-1);
end;
function count(L):integer;
while q<> NIL do
gjatList=0;
begin

gjatList=gjatList+1;
q=q^.pas;
return gjatList;
end;

You might also like