K
Khách

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.

16 tháng 3 2021

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.

Cô ơi, cô chưa khai báo biến i thưa cô

26 tháng 3 2021

Chương trình:

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 s:string;

i,d,dem:integer;

begin

clrscr;

write('Nhap xau S:'); readln(s);

d:=length(s);

dem:=0;

for i:=1 to d do 

  if st[i]=#32 then inc(dem);

writeln(dem);

readln;

end.

31 tháng 12 2021

chj check ib em ạ

31 tháng 12 2021

#include <bits/stdc++.h>

using namespace std;

string s;

int d,i,dem;

int main()

{

cin>>s;

d=s.length();

dem=0;

for (i=0; i<=d-1; i++)

if (s[i]=='a') dem++;

cout<<dem;

return 0;

}

uses crt;

var st:string;

i,d,dem:integer;

ch:char;

begin

clrscr;

write('Nhap xau:'); readln(st);

write('Nhap ki tu:'); readln(ch);

d:=length(st);

dem:=0;

while pos(ch,st)>0 do 

  begin

inc(dem);

delete(st,pos(ch,st),1);

end;

writeln(dem);

readln;

end.

16 tháng 4 2023

program stringManipulation;

var
  st1, st2: string;
  countN, i: integer;

begin
  write('Nhap vao xau ki tu st1: ');
  readln(st1);
  countN := 0;
  for i := 1 to length(st1) do
  begin
    if (st1[i] = 'N') or (st1[i] = 'n') then
    begin
      countN := countN + 1;
    end;
  end;
  writeln('So ky tu N va n trong xau st1 la: ', countN);
  st2 := '';
  for i := 1 to length(st1) do
  begin
    if (st1[i] >= 'A') and (st1[i] <= 'Z') then
    begin
      st2 := st2 + st1[i];
    end;
  end;
  writeln('Cac ky tu in hoa trong xau st1 la: ', st2);
  write('Xau st1 viet theo chieu nguoc lai la: ');
  for i := length(st1) downto 1 do
  begin
    write(st1[i]);
  end;
  readln;
end.

16 tháng 4 2023

st1 = input("Nhập vào xâu kí tự: ")
count_n = 0
st2 = ""
for char in st1:
    if char == 'N' or char == 'n':
        count_n += 1
    if char.isupper():
        st2 += char

print("Số lần xuất hiện của kí tự 'N' và 'n' là:", count_n)
print("Xâu kí tự chỉ chứa kí tự in hoa là:", st2)
print("Xâu kí tự đảo ngược là:", st1[::-1])

16 tháng 4 2023

Program HOC24;

var i,d1,d2: byte;

st1,st2: string[60];

begin

write('Nhap xau st1: '); readln(st1);

//---------------Câu 1-------------------

d1:=0; d2:=0;

for i:=1 to length(st1) do

begin

if st1[i]='A' then d1:=d1+1;

if st1[i]='a' then d2:=d2+1;

end;

writeln('Co ',d1,' ki tu A trong xau');

writeln('Co ',d2,' ki tu a trong xau');

//---------------------- Câu 2 --------------------

st2:='';

for i:=1 to length(st1) do if st1[i] in ['a'..'z'] then st2:=st2+st1[i];

writeln('Xau st2 la: ',st2);

//------------------------------Câu 3--------------------

for i:=1 to length(st1) do st1[i]:=upcase(st1[i]);

write('Xau st1 sau khi in hoa la: ',st1);

//--------------------------------------------------------

readln

end.

16 tháng 4 2023

Chỗ câu 1 câu 2 câu 3 là s vậy ạ