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.
uses crt;
var s,st:string;
dem,d,i,dai,x,j,tam:integer;
a:array[1..255]of string;
b:array[1..255]of integer;
begin
clrscr;
write('nhap xau S:'); readln(s);
d:=length(s);
dem:=0;
st:='';
for i:=1 to d do
begin
if s[i] in ['A'..'z'] then
begin
s[i]:=upcase(s[i]);
st:=st+s[i];
end;
if s[i] in ['0'..'9'] then
begin
dem:=dem+1;
a[dem]:=s[i];
end;
end;
writeln('chuoi ki tu chu cai trong xau S sau khi da bien doi la: ');
dai:=length(st);
for i:=1 to dai do
write(st[i]);
writeln;
for i:=1 to dem do
val(a[i],b[i],x);
for i:=1 to dem-1 do
for j:=i+1 to dem do
if b[i]>b[j] then
begin
tam:=b[i];
b[i]:=b[j];
b[j]:=tam;
end;
writeln('chuoi ki tu chu so trong xau S sau khi da sap xep tang dan la: ');
for i:=1 to dem do
write(b[i]:4);
readln;
end.
Câu 2:
uses crt;
var a,b:array[1..100]of integer;
i,n,t,dem,j,kt,dem1:integer;
begin
clrscr;
readln(n);
for i:=1 to n do
readln(a[i]);
t:=0;
for i:=1 to n do t:=t+a[i];
writeln(t);
dem:=1;
b[1]:=a[1];
for i:=1 to n do
begin
kt:=0;
for j:=1 to dem do
if b[j]=a[i] then kt:=1;
if kt=0 then
begin
inc(dem);
b[dem]:=a[i];
end;
end;
for i:=1 to dem do
begin
dem1:=0;
for j:=1 to n do
if a[j]=b[i] then inc(dem1);
writeln(b[i],' xuat hien ',dem1,' lan');
end;
readln;
end.
1:
#include <bits/stdc++h>
using namespace std;
string a,b;
int main()
{
getline(cin,a);
getline(cin,b);
cout<<a<<" "<<b;
return 0;
}
uses crt;
const fi='dulieu.txt';
var f1:text;
st:string;
i,d:integer;
begin
clrscr;
assign(f1,fi); rewrite(f1);
write('Nhap xau:'); readln(st);
d:=length(st);
for i:=1 to d do
if (st[i] in ['A'..Z']) or (st[i] in ['0'..'9']) or (st[i]=#32) then write(f1,st[i]);
close(f1);
end.
Program HOC24;
var s: string;
tg,d,max,i: byte;
code: integer;
begin
write('Nhap xau : '); readln(s);
// cau a
for i:=1 to length(s) do if s[i] in ['a'..'z'] then write(upcase(s[i]));
//------
writeln;
//-cau b
for i:=length(s) downto 1 do if s[i] in ['0'..'9'] then write(s[i]);
//------
writeln;
//---cau c
d:=0;
for i:= 1 to length(s) do
if s[i] in ['0'..'9'] then
begin
val(s[i],tg,code);
if tg>max then max:=tg;
d:=d+1;
end;
if d=0 then write('Khong co chu so trong day') else write('Chu so lon nhat la : ',max);
readln
end.
uses crt;
var st,st1:string;
d,i,d1,max,x,y:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
writeln('Day cac ki tu thuong doi sang chu hoa la: ');
for i:=1 to d do
if st[i] in ['a'..'z'] then write(upcase(st[i]):4);
st1:='';
for i:=1 to d do
if st[i] in ['0'..'9'] then st1:=st1+st[i];
d1:=length(st1);
for i:=d1 downto 1 do
write(st1[i]:4);
writeln;
max:=0;
for i:=1 to d1 do
begin
val(st1[i],x,y);
if max<x then max:=x;
end;
writeln('Chu so lon nhat trong xau la: ',max);
readln;
end.
uses crt;
const fi='dulieu.txt';
var f1:text;
st:string;
i,d:integer;
begin
clrscr;
assign(f1,fi); rewrite(f1);
write('Nhap xau:'); readln(st);
d:=length(st);
for i:=1 to d do
if (st[i] in ['A'..Z']) or (st[i] in ['0'..'9']) or (st[i]=#32) then write(f1,st[i]);
close(f1);
end.
mk xin chia sẻ code nhé:
#include<cstdio> inline int min( int a, int b ) { return a>b?b:a; } char s[1000005]; int f[1000005], g[1000005]; int main() { int n; scanf("%d", &n); scanf("%s", s); f[0] = g[0] = 0; for(int i=0; i<n; i++) if( s[i] == 'A' ) { f[i+1] = f[i]; g[i+1] = 1 + min( f[i], g[i] ); } else { g[i+1] = g[i]; f[i+1] = 1 + min( f[i], g[i] ); } printf("%d\n", f[n]); }