1. Trang chủ
  2. » Giáo Dục - Đào Tạo

CHUỖI VÀ CÁC BÀI TOÁN TRÊN CHUỖI part 4 ppt

11 377 0
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 11
Dung lượng 25,99 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Trang 1

writeln('±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±±

±±±±±±±±±±±±±±±±±±±±±±±±±±±');

end;

{ -}

Procedure thoat;

var ch:char;

begin

textbackground(4);

textcolor(14);

gotoxy(21,6);

write('ÚÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔ¿');

gotoxy(21,7); write('³ Ban co muon thoat khong (C/K) ? ³');

gotoxy(21,8);

write('ĂÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔÔỖ');

repeat

ch:=readkey;

case upcase(ch) of

'C' : begin textbackground(0);textcolor(7);clrscr;halt;end;

'K' : exit;

end;

until (upcase(ch)='C')or(upcase(ch)='K');

end;

{ -}

Procedure dohoa; {tao do hoa va thuc don}

var i2,t1:integer;

ch:char;

begin

Trang 2

textbackground(9);

textcolor(15);

gotoxy(25,3);write('ÉÍÍÍÍÍÍÍÍÍÍÍÍThuc donÍÍÍÍÍÍÍÍÍÍÍÍ»');

for i:=1 to 9 do

begin

mahoa(menu[i],32);

gotoxy(25,3+i);write('º',menu[i],'º');

end;

gotoxy(25,4+i);write('ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ');

t1:=1;

textbackground(4);

textcolor(14);

gotoxy(26,4);write(menu[1]);

repeat

ch:=readkey;

case ch of

#80 : begin

textbackground(9);

textcolor(15);

gotoxy(26,3+t1);

write(menu[t1]);

if t1=9 then

t1:=1

else t1:=t1+1;

textbackground(4);

textcolor(14);

gotoxy(26,3+t1);

write(menu[t1]);

Trang 3

end;

#72 : begin

textbackground(9);

textcolor(15);

gotoxy(26,3+t1);

write(menu[t1]);

if t1=1 then

t1:=9

else t1:=t1-1;

textbackground(4);

textcolor(14);

gotoxy(26,3+t1);

write(menu[t1]);

end;

#13 : begin

case t1 of

1 :Begin

clrscr;

writeln(' Thu tuc dao nguoc chuoi');

writeln;

write('Nhap so phan tu cua xau:');

readln(n);

writeln;

for i:=1 to n do

Begin

write('Nhap ky tu thu ',i,':');

readln(h);

themcuoi(first,h);

End;

Trang 4

writeln;

write('Chuoi sau khi nhap vao:');

inxau(first);

dao(first);

writeln;

writeln;

write('Chuoi sau khi duoc dao nguoc:');

inxau(first);

readln;

while first<>nil do xoacuoi(first);

dohoa;

End;

2 :Begin

clrscr;

writeln(' Thu tuc dem so phan tu trong xau');

writeln;

write('Nhap vao mot xau bat ky :');

repeat

ch:=readkey;

Begin

write('',ch);

themcuoi(first,h);

End;

until ch=#13;

writeln;

writeln;

f:=chieudai(first);

Trang 5

writeln;

write('chieu dai xau tren la :',f-1);

writeln;

readln;

while first<>nil do xoacuoi(first);

dohoa;

End;

3 :Begin

clrscr;

writeln(' Thu tuc lay chi so cua xau');

writeln;

write('Nhap so phan tu cua xau:');

readln(n);

writeln;

write('nhap vi tri can lay:');

readln(e);

writeln;

for i:=1 to n do

Begin

write('Nhap ky tu thu ',i,':');

readln(h);

themcuoi(first,h);

End;

writeln;

write('Chuoi sau khi nhap vao:');

inxau(first);

writeln;

Trang 6

c1:=chiso(first,e);

writeln;

write('ki tu duoc lay la:',c1);

readln;

while first<>nil do xoacuoi(first);

dohoa;

End;

4 :Begin

clrscr;

writeln(' Thu tuc lay xau ky tu con');

writeln;

write('Nhap so phan tu cua xau:');

readln(n);

writeln;

write('nhap vi tri bat dau lay:');

readln(b1);

writeln;

write('nhap so ki tu can lay:');

readln(b2);

writeln;

for i:=1 to n do

Begin

write('Nhap ky tu thu ',i,':');

readln(h);

themcuoi(first,h);

End;

writeln;

write('Chuoi sau khi nhap vao:');

inxau(first);

Trang 7

writeln;

g:=xaukitucon(first,b1,b2);

writeln;

write('xau duoc lay la:');

inxau(g);

writeln;

readln;

while first<>nil do xoacuoi(first);

dohoa;

End;

5 :Begin

clrscr;

writeln(' Thu tuc in xau khong de quy');

writeln;

write('Nhap so phan tu cua xau:');

readln(n);

writeln;

for i:=1 to n do

Begin

write('Nhap ky tu thu ',i,':');

readln(h);

themcuoi(first,h);

End;

writeln;

write('Chuoi sau khi nhap vao duoc goi bang ham khong de quy :'); inxau(first);

writeln;

readln;

Trang 8

while first<>nil do xoacuoi(first);

dohoa;

End;

6 :Begin

clrscr;

writeln(' Thu tuc in xau de quy');

writeln;

write('Nhap so phan tu cua xau:');

readln(n);

writeln;

for i:=1 to n do

Begin

write('Nhap ky tu thu ',i,':');

readln(h);

themcuoi(first,h);

End;

writeln;

write('Chuoi sau khi nhap vao duoc goi bang ham de quy:');

inxaudq(first);

readln;

while first<>nil do xoacuoi(first);

dohoa;

End;

7 : begin

clrscr;

writeln(' Chuong trinh chuyen doi so thap phan san so nhi phan'); writeln;

writeln(' mo ta qua cac buoc cua stack trong qua trinh chuyen doi'); writeln;

Trang 9

write('Nhap vao so nguyen duong de chuyen doi :');

readln(Nu); lnits(stack1);

writeln;

writeln('Tinh trang stack o cac buoc chuyen doi la');

writeln;

while Nu <> 0 do

begin

R:=Nu mod 2;

Pushs(Stack1,R);

Nu:=Nu div 2;

write('buoc');writestacks(stack1);

writeln;

end;

writeln;

write('Bieu dien co so hai:');

while not Emptys(Stack1) do

begin

Pops(Stack1,R);

write(R:1);

end;

readln;

dohoa;

end;

8 : Begin

clrscr;

writeln(' Su dung phuong phap POLISH de bien doi trung to sang hau to ');

Trang 10

writeln;

writeln(' va neu ro tinh trang cua stack va tung buoc bien doi cua hau to');

writeln;

step:=0;

writeln('Tinh bieu thuc s:=(a+b-c)*d/e-(f-g)');

writeln;

writeln(' va s:=(d^e-f)*(g/h+i)-a/b+c');

writeln;

writeln(' voi a=27,b=3,c=1,d=6,e=2,f=9,g=12,h=4,i=1');

writeln;

write('Nhap chuoi bieu thuc s:');

readln(s);

writeln;

Writeln('Bieu thuc ban dau:',s);

writeln;

writeln('Buoc Phan tu Bieu thuc hau to Tinh trang stack');

writeln;

kt:=Polish(s,s);

writeln;

if kt then

begin writeln;write('Bieu thuc hau to:',s)end

else

begin writeln;write('Khong dung la bieu thuc theo yeu cau');end;

writeln;

kt:=Value(s,t);

writeln;

if kt then

begin writeln;write('Gia tri tinh duoc:',t:0:2)end

Trang 11

else

begin writeln;write('khong tinh duoc');end;

readln;

dohoa;

END;

9: thoat;

end;

end;

#59 : begin dohoa;end;

#60 : begin dohoa;end;

#27 : begin thoat;dohoa;end;

end;

until ch=#27;

end;

{ -}

Begin

taonen;

dohoa;

end

Ngày đăng: 13/07/2014, 07:20

TỪ KHÓA LIÊN QUAN

🧩 Sản phẩm bạn có thể quan tâm

w