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.
1) Viet chuong trinh nhap xau S1, tao xau S2 bao gom tat ca cac ki tu da xoa het chu so trong xau S1
#include <bits/stdc++.h>
using namespace std;
string s1;
int d,i;
int main()
{
getline(cin,s1);
d=s1.length();
for (i=0; i<=d-1; i++)
if ((s1[i]<48) or (s1[i]>57)) cout<<s1[i];
return 0;
}
#include <bits/stdc++.h>
using namespace std;
string s1;
int d,i;
int main()
{
getline(cin,s1);
d=s1.length();
for (i=0; i<=d-1; i++)
if ((s1[i]>=48) and (s1[i]<=57)) cout<<s1[i];
return 0;
}
uses crt;
var a:array[1..100]of integer;
i,n,t:integer;
begin
clrscr;
write('n='); readln(n);
if (n>0) and (n<=100) then
begin
t:=0;
for i:=1 to n do
begin
write('a[',i,']='); readln(a[i]);
if (a[i] mod 2=0) or (a[i] mod 2=1) then t:=t+a[i];
end;
writeln('tong cac phan tu chan hoac le trong day la: ',t);
end
else writeln('vui long nhap lai');
readln;
end.
uses crt;
var a:array[1..250]of integer;
i,n,t:integer;
begin
clrscr;
readln(n);
t:=0;
for i:=1 to n do readln(a[i]);
for i:=1 to n do write(a[i]:4);
writeln;
for i:=1 to n do t:=t+a[i];
writeln(t);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
double a,b;
int main()
{
cin>>a>>b;
cout<<"a truoc khi doi la:"<<fixed<<setprecision(2)<<a<<endl;
cout<<"b truoc khi doi la:"<<fixed<<setprecision(2)<<b<<endl;
swap(a,b);
cout<<"a sau khi doi la:"<<fixed<<setprecision(2)<<a<<endl;
cout<<"b sau khi doi la:"<<fixed<<setprecision(2)<<b;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
double a,b,cv,dt;
int main()
{
cin>>a>>b;
cv=(a+b)*2;
dt=a*b;
cout<<fixed<<setprecision(2)<<cv<<endl;
cout<<fixed<<setprecision(2)<<dt;
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int dv,ch,tr,n;
int main()
{
cin>>n;
dv=n%10;
ch=n/10; ch=ch%10;
tr=n/100;
cout<<dv<<endl;
cout<<ch<<endl;
cout<<tr;
return 0;
}
uses crt;
var a:array[1..100]of integer;
i,n,dem:integer;
begin
clrscr;
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
dem:=0;
for i:=1 to n do
if a[i] mod 3=0 then
begin
inc(dem);
write(a[i]:4);
end;
writeln;
writeln('So phan tu chia het cho 3 la: ',dem);
readln;
end.
uses crt;
var s:string;
ktu:char;
i,d,dem:integer;
begin
clrscr;
write('Nhap xau:'); readln(s);
write('Nhap ki tu:'); readln(ktu);
d:=length(s);
dem:=0;
for i:=1 to d do
if s[i]=ktu then inc(dem);
writeln('So ki tu ',ktu,' trong xau ',s,' la: ',dem);
for i:=1 to d do
if s[i]=ktu then delete(s,i,1);
writeln('Xau sau khi xoa cac ki tu ',ktu,' la: ',s);
readln;
end.