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 st,k,t:string;
d,dem,i:integer;
begin
clrscr;
readln(st);
d:=length(st);
k='';
dem=1;
for i:=2 to d do
begin
if st[i]=st[i-1] then inc(dem);
if st[i]<>st[i-1] then
btegin
str(dem,t);
if dem>1 then k:=k+t+st[i-1];
else k:=k+st[i-1];
dem=1;
end;
if (i=d) then
begin
str(dem,t);
if dem>1 then k:=k+t+st[i];
else k:=k+st[i];
end;
end;
write(k);
readln;
end.
Var a:array[1..100] of integer;
i,s:integer;
Begin
For i:=1 to 100 do
Begin
Write('Nhap phan tu thu ',i,' = ');readln(a[i]);
If a[i] mod 2 <> 0 then s:=s+a[i];
End;
Write('Tong la ',s);
Readln;
End.
Câu 1:
const fi='dulieu.dat';
fo='thaythe.out';
var f1,f2:text;
a:array[1..100]of string;
n,d,i,vt:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
n:=0;
while not eof(f1) do
begin
n:=n+1;
readln(f1,a[n]);
end;
for i:=1 to n do
begin
d:=length(a[i]);
vt:=pos('anh',a[i]);
while vt<>0 do
begin
delete(a[i],vt,3);
insert('em',a[i],vt);
vt:=pos('anh',a[i]);
end;
end;
for i:=1 to n do
writeln(f2,a[i]);
close(f1);
close(f2);
end.
Câu 2:
uses crt;
const fi='mang.inp';
fo='sapxep.out';
var f1,f2:text;
a:array[1..100]of integer;
i,n,tam,j:integer;
begin
clrscr;
assign(f1,fi); rewrite(f1);
assign(f2,fo); rewrite(f2);
write('Nhap n='); readln(n);
for i:=1 to n do
begin
write('A[',i,']='); readln(a[i]);
end;
for i:=1 to n do
write(f1,a[i]:4);
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]>a[j] then
begin
tam:=a[i];
a[i]:=a[j];
a[j]:=tam;
end;
for i:=1 to n do
write(f2,a[i]:4);
close(f1);
close(f2);
end.
Câu 4:
fucntion tong(x:integer):integer;
var st:string;
d,i,n,y,t:integer;
begin
str(x,st);
d:=length(st);
t:=0;
for i:=1 to d do
begin
val(st[i],n,y);
t:=t+n;
end;
tong:=t;
end;
Câu 2:
const fi='bai2.inp';
fo='bai2.out';
var f1,f2:text;
a:array[1..100]of integer;
n,i,t:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,n);
for i:=1 to n do
read(f1,a[i]);
t:=0;
for i:=1 to n do
t:=t+a[i];
writeln(f2,t);
close(f1);
close(f2);
end.