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.
var i:longint; thap:real;
nhi:string;
begin
readln(nhi); thap:=0;
for i:=1 to length(nhi) do
begin
thap:=thap + (ord(nhi[i])-48)* exp(ln(2)*(length(nhi)-i));
end;
write(thap:2:0);
readln
end.
uses crt;
var st:string;
i,j,n,d,x,y:integer;
kq,lt:longint;
begin
clrscr;
write('nhap so nhi phan:'); readln(st);
d:=length(st);
kq:=0;
for i:=1 to d do
begin
lt:=1;
for j:=1 to d-i do
lt:=lt*2;
val(st[i],x,y);
kq:=kq+x*lt;
end;
writeln(st,' doi sang he 10 la: ',kq);
readln;
end.
def binary_search(arr, x):
left = 0
right = len(arr) - 1
while left <= right:
mid = (left + right) // 2
if arr[mid] == x:
return mid
elif arr[mid] < x:
right = mid - 1
else:
left = mid + 1
return -1
# Sử dụng hàm để tìm kiếm giá trị 5 trong dãy sắp xếp giảm dần [9, 8, 6, 5, 3, 1]
arr = [9, 8, 6, 5, 3, 1]
x = 5
result = binary_search(arr, x)
if result != -1:
print("Element is present at index", str(result))
else:
print("Element is not present in array")
uses crt;
var st:string;
i,d,t,x,y,kq,j,lt:integer;
begin
clrscr;
readln(st);
d:=length(st);
kq:=0;
for i:=1 to d do
begin
lt:=1;
for j:=1 to d-i do
begin
val(st[i],x,y);
lt:=lt*x;
end;
kq:=kq+x*lt;
end;
writeln(kq);
readln;
end.
#include <bits/stdc++.h>
using namespace std;
double a;
int main()
{
cin>>a;
cout<<fixed<<setprecision(2)<<a*a;
return 0;
}
uses crt;
var a,t,dem:integer;
begin
clrscr;
t:=0;
dem:=0;
repeat
write('Nhap a='); readln(a);
if (a mod 2=0) and (a mod 3=0) then
begin
t:=t+a;
dem:=dem+1;
end;
until a=0;
writeln('Trung binh cong cua cac so chia het cho 3 va 2 la: ',t/dem:4:2);
readln;
end.
uses crt;
const fi='baitap.txt';
var f1:text;
a,b,c,d:array[1..100]of real;
i,n:integer;
begin
clrscr;
assign(f1,fi); reset(f1);
n:=0;
while not eof(f1) do
begin
n:=n+1;
readln(f1,a[n],b[n],c[n],d[n]);
end;
for i:=1 to n do
writeln(sqrt(sqr(a[i]-c[i])+sqr(b[i]-d[i])):4:3);
close(f1);
readln;
end.
Cách 1: Có sử dụng chương trình con
uses crt;
var st:string;
{------------chuong-trinh-con-------------------}
function doi(st1:string):string;
var i,d:integer;
begin
d:=length(st1);
for i:=1 to d do
st1[i]:=upcase(st1[i]);
doi:=st1;
end;
{-------------------chuong-trinh-chinh--------------------}
begin
clrscr;
write('Nhap xau:'); readln(st);
writeln(doi(st));
readln;
end.
Cách 2: Không sử dụng chương trình con
uses crt;
var st:string;
i,d:integer;
begin
clrscr;
write('Nhap xau:'); readln(st);
d:=length(st);
for i:=1 to d do
st[i]:=upcase(st[i]);
writeln(st);
readln;
end.
uses crt;
var st:string;
i,j,n,d,x,y:integer;
kq,lt:longint;
begin
clrscr;
write('nhap so nhi phan:'); readln(st);
d:=length(st);
kq:=0;
for i:=1 to d do
begin
lt:=1;
for j:=1 to d-i do
lt:=lt*2;
val(st[i],x,y);
kq:=kq+x*lt;
end;
writeln(st,' doi sang he 10 la: ',kq);
readln;
end.
uses crt;
var x,i,luu:integer;
nhiphan,thapphan,kt,test:string;
a: array [1..15] of integer;
begin
clrscr;
write('So nhi phan: ');readln(nhiphan);
str(10, test);
if nhiphan >= test then begin
i:= 1; x:= 1;
repeat
x:= x + 1;
luu:= x;
repeat
a[i]:= luu mod 2;
luu:= luu div 2;
i:= i + 1;
until luu = 0;
str(a[i - 1], thapphan);
for i:= i - 2 downto 1 do
begin
str(a[i], kt);
thapphan:= thapphan + kt;
end;
until thapphan = nhiphan;
end
else if nhiphan < test then
if nhiphan = '0'then x:= 0
else if nhiphan = '1' then x:= 1;
write('So thap phan la: ',x);
readln
end.