Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
uses crt;
var st:string[30];
i,d,dem,dem1:integer;
ktu:char;
begin
clrscr;
write('Nhap cau:'); readln(st);
d:=length(st);
while st[1]=#32 do
begin
delete(st,1,1);
d:=length(st);
end;
while st[length(st)]=#32 do
begin
delete(st,length(st),1);
end;
for i:=1 to length(st) do
if (st[i]=#32) and (st[i+1]=#32) then delete(st,i,1);
dem:=0;
for i:=1 to length(st) do
if st[i]=#32 then inc(dem);
writeln('So tu trong cau la: ',dem-1);
write('Nhap ki tu:'); readln(ktu);
dem1:=0;
for i:=1 to length(st) do
if (st[i]=#32) and (st[i+1]=ktu) then inc(dem1);
writeln('Trong cau co ',dem1,' tu bat dau bang ki tu ',ktu);
readln;
end.
Bài 1:
uses crt;
var S:String;
vt:integer;
begin
clrscr;
Write(‘Nhap 1 xau:’); Readln(S);
While pos(‘nang’,s)>0 do
Begin
Vt:= pos(‘nang’,s);
Delete(s,vt,4);
Insert(‘mua’,s ,vt);
End;
Writeln(‘Xau sau khi thay the ’,s);
Readln;
End.
Bài 2:
uses crt;
var st:string;
d,i,kt:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
kt:=0;
for i:=1 to d do
if st[i]<>st[d-i+1] then kt:=1;
if kt=0 then writeln(st,' la xau doi xung')
else writeln(st,' khong la xau doi xung');
readln;
end.
uses crt;
var st:string;
i,dem:integer;
begin
clrscr;
readln(st);
writeln(length(st));
for i:=5 to 8 do write(st[i]);
writeln;
dem:=0;
for i:=1 to length(st) do
if st[i]='b' then dem:=dem+1;
writeln(dem);
readln;
end.
Program HOC24;
var S: string;
d,i: byte;
begin
write('S= '); readln(s);
For i:= length(s) downto 1 do write(s[i]);
writeln;
while s[length(s)]=#32 do delete(s,length(s),1);
while pos(#32#32,s)<>0 do delete(s,pos(#32#32,s),1);
while s[1]=#32 do delete(s,1,1);
d:=0;
for i:=1 to length(s) do d:=d+1;
write('So tu :',d);
readln
end.
uses crt;
var s:string[200];
i,d,dem:integer;
begin
clrscr;
write('Nhap xau:'); readln(s);
d:=length(s);
write('Xau viet theo chieu nguoc la: ');
for i:=d downto 1 do
write(st[i]);
writeln;
dem:=0;
for i:=1 to d do
if st[i]=#32 then inc(dem);
writeln('So tu la: ',dem);
readln;
end.
câu 1 Uses Crt;
Var St:String;
dem: Array[‘A’..’Z’] Of Byte
; i:Byte;
ch:Char;
Begin Write(‘Nhap xau St: ‘);
Readln(St);
{Khởi tạo mảng} For ch:=’A’ To ‘Z’ Do dem[ch]:=0;
{Duyệt xâu} For i:=1 To Length(St) Do If Upcase(St[i]) IN [‘A’..’Z’] Then Inc(dem[Upcase(St[i])]);
{Liệt kê các ký tự ra màn hình} For ch:=’A’ To ‘Z’ Do If dem[ch]>0 Then Writeln(ch,’ : ’,dem[ch]);
Readln;
uses crt;
var s:string;
i,d:integer;
begin
clrscr;
write('Nhap xau S:'); readln(s);
d:=length(s);
for i:=1 to d do
if (s[i] in ['a'..'z']) or (s[i] in ['A'..'Z']) then delete(s,i,1);
writeln('Xau sau khi xoa het ki tu chu la: ',s);
readln;
end.
program bai_10_chuong_4;
uses crt;
var
s: string[100];
i, dem: integer;
Begin
clrscr;
write('Nhap xau vao:'); readln(s); dem:= 0;
for i:= 1 to length(s) do
if ('0'<=s[i]) and(s[i]<=’9') then dem:=dem+l;
Writeln('Trong xau s co '»dem,' chu so thap phan');
readln;
End.
uses crt;
var st:string[100];
i,d,kt:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
kt:=0;
for i:=1 to length(st) do
if st[i]<>st[length(st)-i+1] then kt:=1;
if kt=0 then write('Xau doi xung')
else writeln('Xau khong doi xung');
readln;
end.
Program HOC24;
var s: string;
x: char;
d: byte;
begin
write('Nhap xau: '); readln(s);
write('Nhap ki tu: '); readln(x);
d:=0;
for i:=1 to length(s) do if s[i]=x then d:=d+1;
if d=0 then write('Ki tu do khong xuat hien trong xau') else write('Ki tu do xuat hien trong xau');
readln
end.
#include <bits/stdc++.h>
using namespace std;
string st;
int d,i,dem;
int main()
{
getline(cin,st);
d=st.length();
dem=0;
for (i=0; i<d; i++) if (st[i]=' ') dem++;
cout<<dem+1;
return 0;
}