viết chương trình nhập vào 1 xâu bất kì tách xâu đó thành 2 xâu tương đương nhau về độ dài và đưa ra xâu có độ dài lớn hơn Thonny
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.
Câu 1:
uses crt;
var st:string;
d,i,dem:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
write('Xau sau khi xoa so la: ');
for i:=1 to d do
if not(st[i] in ['0'..'9']) then write(st[i]);
writeln;
dem:=0;
for i:=1 to d do
if st[i]=#32 then inc(dem);
writeln('Xau co ',dem,' dau cach');
writeln('Do dai cua xau la: ',d);
readln;
end.
Câu 2:
uses crt;
const fi='kq.out';
var st1,st2:string;
f1:text;
begin
clrscr;
write('Nhap xau thu 1:'); readln(st1);
write('Nhap xau thu 2:'); readln(st2);
assign(f1,fi); rewrite(f1);
if length(st2)>length(st1) then writeln(f1,st2)
else writeln(f1,st1);
close(f1);
end.
#include <bits/stdc++.h>
using namespace std;
string st1,st2;
int d1,d2;
int main()
{
cin>>st1>>st2;
d1=st1.length();
d2=st2.length();
if (d1<d2) cout<<st1;
else cout<<st2;
return 0;
}
program so_sanh;
uses crt;
var a, b: string;
begin
clrscr;
write('nhap xau thu nhat: ');readln(a);
write('nhap xau thu hai: ');readln(b);
if length(a)<length(b) then write(a) else write(b);
readln
end.
Uses crt;
Var st1,st2:string;
D1,d2:integer;
Begin
Clrscr;
Write('nhap xau thu 1:'); readln(st1);
Write('nhap xau thu 2:'); readln(st2);
D1:=length(st1);
D2:=length(st2);
If d1<d2 then write(st1)
Else writeln(st2);
Readln;
End.
#include <bits/stdc++.h>
using namespace std;
string st;
int d,i;
int main()
{
getline(cin,st);
d=st.length()
for (i=0; i<=d-1; i++)
if (('a'<=st[i]) and (st[i]<='z')) st[i]=st[i]+32;
for (i=0; i<=d-1; i++)
cout<<st[i];
return 0;
}
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.