Trang chủ
Bài viết mới
Diễn đàn
Bài mới trên hồ sơ
Hoạt động mới nhất
VIDEO
Mùa Tết
Văn Học Trẻ
Văn Học News
Media
New media
New comments
Search media
Đại Học
Đại cương
Chuyên ngành
Triết học
Kinh tế
KHXH & NV
Công nghệ thông tin
Khoa học kĩ thuật
Luận văn, tiểu luận
Phổ Thông
Lớp 12
Ngữ văn 12
Lớp 11
Ngữ văn 11
Lớp 10
Ngữ văn 10
LỚP 9
Ngữ văn 9
Lớp 8
Ngữ văn 8
Lớp 7
Ngữ văn 7
Lớp 6
Ngữ văn 6
Tiểu học
Thành viên
Thành viên trực tuyến
Bài mới trên hồ sơ
Tìm trong hồ sơ cá nhân
Credits
Transactions
Xu: 0
Đăng nhập
Đăng ký
Có gì mới?
Tìm kiếm
Tìm kiếm
Chỉ tìm trong tiêu đề
Bởi:
Hoạt động mới nhất
Đăng ký
Menu
Đăng nhập
Đăng ký
Install the app
Cài đặt
Chào mừng Bạn tham gia Diễn Đàn VNKienThuc.com -
Định hướng Forum
Kiến Thức
- HÃY TẠO CHỦ ĐỀ KIẾN THỨC HỮU ÍCH VÀ CÙNG NHAU THẢO LUẬN Kết nối:
VNK X
-
VNK groups
| Nhà Tài Trợ:
BhnongFood X
-
Bhnong groups
-
Đặt mua Bánh Bhnong
CÔNG NGHỆ
Công Nghệ Thông Tin
Code
Pascal kiểu mảng và kiểu xâu
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Trả lời chủ đề
Nội dung
<blockquote data-quote="Trung Kiên" data-source="post: 136328" data-attributes="member: 3"><p><span style="font-family: 'courier new'"> <span style="font-size: 15px">Kiểu xâu:</span></span></p><p><span style="font-family: 'courier new'"><span style="font-size: 15px">1.</span></span></p><p><span style="font-family: 'courier new'"><span style="font-size: 15px"></span>[code][COLOR=#000000] [SIZE=4]Uses Crt;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]Var St:String;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] i:Byte;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]Begin[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] Write(‘Nhap xau St: ‘); Readln(St);[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] For i:=1 to length(St) do St[i]:=Upcase(St[i]);[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] Write(‘Xau ket qua: ‘, St);[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] Readln;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]End.[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[/code] <span style="font-size: 15px"></span></span></p><p><span style="font-family: 'courier new'"><span style="font-size: 15px"></span></span></p><p><span style="font-family: 'courier new'"><span style="font-size: 15px">2.</span></span></p><p><span style="font-family: 'courier new'"><span style="font-size: 15px"></span>[code][COLOR=#000000] [SIZE=4]Uses Crt;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]Var St:String;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] i:Byte;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]Begin[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] Write(‘Nhap xau St: ‘); Readln(St);[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] For i:=1 to length(St) do[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] If St[i] IN [‘A’..’Z’] Then St[i]:=CHR(ORD(St[i])+32);[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] Write(‘Xau ket qua: ‘, St);[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] Readln;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]End.[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[/code] <span style="font-size: 15px"></span></span></p><p><span style="font-family: 'courier new'"><span style="font-size: 15px"></span></span></p><p><span style="font-family: 'courier new'"><span style="font-size: 15px">3.</span></span></p><p><span style="font-family: 'courier new'"><span style="font-size: 15px"></span>[code][COLOR=#000000] [SIZE=4]Uses Crt;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]Var St:String;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] i,d:Byte;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]Begin[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] Write(‘Nhap xau St: ‘); Readln(St);[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] For i:=1 to length(St) do[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] If St[i] IN [‘0’..’9’] Then d:=d+1;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] Write(‘So ky tu chu so trong xau: ‘, d);[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] Readln;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]End.[/SIZE][/COLOR]</span></p><p> <span style="font-family: 'courier new'">[SIZE=4]</span></p><p><span style="font-family: 'courier new'">[/SIZE]</span></p><p><span style="font-family: 'courier new'">[/code] <span style="font-size: 15px"></span></span></p><p><span style="font-family: 'courier new'"><span style="font-size: 15px"></span></span></p><p><span style="font-family: 'courier new'"><span style="font-size: 15px">4.</span></span></p><p><span style="font-family: 'courier new'"><span style="font-size: 15px"></span>[code][COLOR=#000000] [SIZE=4]Uses Crt;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]Var St:String;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]Procedure XoaTrangThua(Var St:String);[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]Begin[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] {Xóa các ký tự trắng ở đầu xâu}[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] While St[1]=#32 Do Delete(St,1,1);[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] {Xóa các ký tự trắng ở cuối xâu}[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] While St[Length(St)]=#32 Do Delete(St,Length(St),1);[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] {Xóa các ký tự trắng ở giữa xâu}[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] While POS(#32#32,St)<>0 Do Delete(St,POS(#32#32,St),1);[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]End;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'"></span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]Begin[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] Write(‘Nhap xau St: ‘); Readln(St);[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] XoaTrangThua(St);[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] Write(‘Xau sau khi xoa cac ky tu trang thua: ‘, St);[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] Readln;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]End.[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[/code] <span style="font-size: 15px"></span></span></p><p><span style="font-family: 'courier new'"><span style="font-size: 15px"></span></span></p><p><span style="font-family: 'courier new'"><span style="font-size: 15px">5.</span></span></p><p><span style="font-family: 'courier new'"><span style="font-size: 15px"></span>[code][COLOR=#000000] [SIZE=4]Uses Crt;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]Var St:String;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]Procedure XoaTrangThua(Var St:String);[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]Begin[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] {Xóa các ký tự trắng ở đầu xâu}[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] While St[1]=#32 Do Delete(St,1,1);[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] {Xóa các ký tự trắng ở cuối xâu}[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] While St[Length(St)]=#32 Do Delete(St,Length(St),1);[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] {Xóa các ký tự trắng ở giữa xâu}[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] While POS(#32#32,St)<>0 Do Delete(St,POS(#32#32,St),1);[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]End;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'"></span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]Begin[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] Write(‘Nhap xau St: ‘); Readln(St);[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] XoaTrangThua(St);[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] St:=St+#32;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] Writeln(‘Liet ke cac tu trong xau: ‘);[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] While POS(#32,St)<>0 Do[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] Begin[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] Writeln(Copy(St,1,POS(#32,St)));[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] Delete(St,1,POS(#32,St));[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] End;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] Readln;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]End.[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[/code] <span style="font-size: 15px"></span></span></p><p><span style="font-family: 'courier new'"><span style="font-size: 15px"></span></span></p><p><span style="font-family: 'courier new'"><span style="font-size: 15px">6.</span></span></p><p><span style="font-family: 'courier new'"><span style="font-size: 15px"></span>[code][COLOR=#000000] [SIZE=4]Uses Crt;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]Var St:String;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'"></span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]{Giải thuật không đệ qui}[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]Function XauDao(St:String):String;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]Var S:String;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] i:Byte;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]Begin[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] S:=’’;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] For i:=Length(St) DowTo 1 Do S:=S+St[i];[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] XauDao:=S;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]End;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'"></span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]{Giải thuật đệ qui}[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]Function DeQui(St:String):String;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]Begin[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] If Length(St)<=1 Then DeQui:=St[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] Else DeQui:=St[Length(St)] + DeQui(Copy(St,1,Length(St)-1));[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]End;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'"></span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]Begin[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] Write(‘Nhap xau St: ‘); Readln(St);[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] Write(‘Xau dao nguoc: ‘, XauDao(St));[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4] Readln;[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[COLOR=#000000] [SIZE=4]End.[/SIZE][/COLOR]</span></p><p><span style="font-family: 'courier new'">[/code]</span></p></blockquote><p></p>
[QUOTE="Trung Kiên, post: 136328, member: 3"] [FONT=courier new] [SIZE=4]Kiểu xâu: 1. [/SIZE][code][COLOR=#000000] [SIZE=4]Uses Crt;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]Var St:String;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] i:Byte;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]Begin[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] Write(‘Nhap xau St: ‘); Readln(St);[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] For i:=1 to length(St) do St[i]:=Upcase(St[i]);[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] Write(‘Xau ket qua: ‘, St);[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] Readln;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]End.[/SIZE][/COLOR] [/code] [SIZE=4] 2. [/SIZE][code][COLOR=#000000] [SIZE=4]Uses Crt;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]Var St:String;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] i:Byte;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]Begin[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] Write(‘Nhap xau St: ‘); Readln(St);[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] For i:=1 to length(St) do[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] If St[i] IN [‘A’..’Z’] Then St[i]:=CHR(ORD(St[i])+32);[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] Write(‘Xau ket qua: ‘, St);[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] Readln;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]End.[/SIZE][/COLOR] [/code] [SIZE=4] 3. [/SIZE][code][COLOR=#000000] [SIZE=4]Uses Crt;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]Var St:String;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] i,d:Byte;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]Begin[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] Write(‘Nhap xau St: ‘); Readln(St);[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] For i:=1 to length(St) do[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] If St[i] IN [‘0’..’9’] Then d:=d+1;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] Write(‘So ky tu chu so trong xau: ‘, d);[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] Readln;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]End.[/SIZE][/COLOR] [SIZE=4] [/SIZE] [/code] [SIZE=4] 4. [/SIZE][code][COLOR=#000000] [SIZE=4]Uses Crt;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]Var St:String;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]Procedure XoaTrangThua(Var St:String);[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]Begin[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] {Xóa các ký tự trắng ở đầu xâu}[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] While St[1]=#32 Do Delete(St,1,1);[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] {Xóa các ký tự trắng ở cuối xâu}[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] While St[Length(St)]=#32 Do Delete(St,Length(St),1);[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] {Xóa các ký tự trắng ở giữa xâu}[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] While POS(#32#32,St)<>0 Do Delete(St,POS(#32#32,St),1);[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]End;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]Begin[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] Write(‘Nhap xau St: ‘); Readln(St);[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] XoaTrangThua(St);[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] Write(‘Xau sau khi xoa cac ky tu trang thua: ‘, St);[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] Readln;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]End.[/SIZE][/COLOR] [/code] [SIZE=4] 5. [/SIZE][code][COLOR=#000000] [SIZE=4]Uses Crt;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]Var St:String;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]Procedure XoaTrangThua(Var St:String);[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]Begin[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] {Xóa các ký tự trắng ở đầu xâu}[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] While St[1]=#32 Do Delete(St,1,1);[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] {Xóa các ký tự trắng ở cuối xâu}[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] While St[Length(St)]=#32 Do Delete(St,Length(St),1);[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] {Xóa các ký tự trắng ở giữa xâu}[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] While POS(#32#32,St)<>0 Do Delete(St,POS(#32#32,St),1);[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]End;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]Begin[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] Write(‘Nhap xau St: ‘); Readln(St);[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] XoaTrangThua(St);[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] St:=St+#32;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] Writeln(‘Liet ke cac tu trong xau: ‘);[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] While POS(#32,St)<>0 Do[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] Begin[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] Writeln(Copy(St,1,POS(#32,St)));[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] Delete(St,1,POS(#32,St));[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] End;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] Readln;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]End.[/SIZE][/COLOR] [/code] [SIZE=4] 6. [/SIZE][code][COLOR=#000000] [SIZE=4]Uses Crt;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]Var St:String;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]{Giải thuật không đệ qui}[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]Function XauDao(St:String):String;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]Var S:String;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] i:Byte;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]Begin[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] S:=’’;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] For i:=Length(St) DowTo 1 Do S:=S+St[i];[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] XauDao:=S;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]End;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]{Giải thuật đệ qui}[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]Function DeQui(St:String):String;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]Begin[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] If Length(St)<=1 Then DeQui:=St[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] Else DeQui:=St[Length(St)] + DeQui(Copy(St,1,Length(St)-1));[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]End;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]Begin[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] Write(‘Nhap xau St: ‘); Readln(St);[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] Write(‘Xau dao nguoc: ‘, XauDao(St));[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4] Readln;[/SIZE][/COLOR] [COLOR=#000000] [SIZE=4]End.[/SIZE][/COLOR] [/code][/FONT] [/QUOTE]
Tên
Mã xác nhận
Gửi trả lời
CÔNG NGHỆ
Công Nghệ Thông Tin
Code
Pascal kiểu mảng và kiểu xâu
Top