1. Trang chủ
  2. » Cao đẳng - Đại học

BAI TOAN TACH CHUOI

2 7 0

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

THÔNG TIN TÀI LIỆU

Cho biet vi tri dau cua chuoi con trong chuoi ban dau va do dai cua chuoi con} Program b7; Var st,stcon:string; code,i:word; Begin Writeln'Ban hay nhap vao mot chuoi: '; Readlnst; Writel[r]

(1){b6-26-02.Viet ct nhap vao mot chuoi, sau muon tach cac chuoi nao thi khai bao vi tri dau tien va dai cua chuoi can tach Neu khong tach nua thi nhan k} Program b6; Var st,stcon:string; n,i,l:word; kt:char; Begin Repeat Write('Nhap mot chuoi: '); Readln(st); Write('Ban muon tach tu vi tri nao: '); Readln(n); Write('Ban tach bao nhieu ki tu: '); Readln(l); stcon:=''; For i:=n to (n+l-1) stcon:=stcon+st[i]; Writeln('Chuoi sau tach la: ',stcon); Write('Enter de tiep tuc'); Readln; Repeat Write('Ban muon tach tiep khong(C/K) : '); Readln(kt); Until upcase(kt) in ['C','K']; Until upcase(kt)='K'; End {b7-26-01 Viet chuong trinh nhap vao mot chuoi ki tu va mot chuoi Cho biet vi tri dau cua chuoi chuoi ban dau va dai cua chuoi con} Program b7; Var st,stcon:string; code,i:word; Begin Writeln('Ban hay nhap vao mot chuoi: '); Readln(st); Writeln('Ban hay nhap them mot chuoi con: '); Readln(stcon); Writeln('Do dai cua chuoi "',stcon,'" la :',length(stcon)); code:=pos(stcon,st); Write('Vi tri cua chuoi "',stcon,'" chuoi "',st,'" la :',code:5); Readln; End {nhap vao mot chuoi dem co bao nhieu chu} Program b8; Var st,tg:string; d,i,code:word; BEgin Write('Nhap vao mot chuoi: '); Readln(st); (2) While(st[1]=' ') delete(st,1,1); While( st[length(st)]=' ') delete(st,length(st),1); tg:=' '; Repeat code:=pos(tg,st); delete(st,code,1); Until code=0; Write(st); d:=0; For i:=1 to length(st) If st[i]=#32 then inc(d); Write('So chu chuoi la: ',d+1); Readln; End (3)

Ngày đăng: 09/09/2021, 22:12

Xem thêm:

w