1. Viết chương trình nhập vào 1 xâu họ tên sau đó đưa ra màn hình xâu chứa tên 2. Viết chương trình nhập vào 1 xâu in ra màn hình xâu đó sau khi đã đổi tất cả chữ in thường thành 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.
#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;
}
2:
#include <bits/stdc++.h>
using namespace std;
string st1,st2;
int d1,d2;
int main()
{
getline(cin,st1);
getline(cin,st2);
d1=st1.length();
d2=st2.length();
if (d1>d2) cout<<st1;
else cout<<st2;
return 0;
}
Program Xau;
Uses crt;
Var St: String;
i: longint;
Begin
Clrscr;
Write('Nhap xau: '); Readln(St);
For i:=1 to length(St) do
St[i] := Upcase(St[i]);
Write('St = ',St);
Readln
End.
uses crt;
var st1,st2:string;
begin
clrscr;
readln(st1,st2);
if st1>st2 then writeln('Xau st1 lon hon')
else if st2>st1 then writeln('Xau st2 lon hon')
else writeln('Hai xau bang nhau');
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.
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)