Viết chương trình nhập 1 xâu dưới họ tên bất kì. Đưa ra màn hình xâu họ tên đã được chuyển hóa ( xóa dấu cách thừa, chuyển chữ cái đầu bằng chữ in hoa)
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:
ho_ten = input("Nhập họ tên: ")
tach_ho_ten = ho_ten.split()
if len(tach_ho_ten) > 1:
ten = tach_ho_ten[-1]
print("Tên của bạn là:", ten)
else:
print("Nhập sai định dạng họ tên")
Câu 2:
s = input("Nhập xâu: ")
hoa = s.upper()
print(hoa)
#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;
i: byte;
begin
write('Nhap xau: '); readln(s);
for i:=1 to length(s) do if (s[i]<>#32) and (s[i] in 'A'..'z') then
begin
upcase(s[i]); write(s[i]);
end;
readln
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 HOC24;
var s: string;
i,x: byte;
begin
readln(s);
//-----------Câu a
while s[1]=#32 do delete(s,1,1);
while s[length(s)]=#32 do delete(s,length(s),1);
while pos(#32#32,s)<>0 do delete(s,pos(#32#32,1);
writeln(s);
//-------------Câu b
s[1]:=upcase(s[1]);
for i:=1 to length(s) do
if s[i]=#32 upcase(s[i+1]);
writeln(s);
//--------------Câu c
for i:=1 to length(s) do
if s[i]=#32 then x:=i;
for i:=x+1 to length(s) do
write(s[i]);
//---------------------------
readln
end.
Program HOC24;
var s: string;
n,i: integer;
a: array[1..32000] of string;
function chuyen(x: string): string;
begin
x[1]:=upcase(x[1]);
chuyen:=x;
end;
begin
write('Nhap xau : '); readln(s);
while s[1]=#32 do delete(s,1,1);
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);
writeln('Xau sau khi xoa dau cach : ',s);
s:=s+' ';
while length(s)<>0 do
begin
st:=copy(s,1,pos(' ',s)-1);
n:=n+1;
a[n]:=st;
delete(s,1,pos(' ',s));
end;
for i:=1 to n do write(chuyen(a[i]),' ');
readln
end.