
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.


Nguyên tắc của phương pháp chuyển đổi từ hệ cơ số 10 sang hệ cơ số 2 là lấy số cần chuyển đổi chia cho 2 (kết quả chỉ lấy phần nguyên), sau đó tiếp tục lấy kết quả chia 2 (và cũng chỉ lấy phần nguyên), kết quả số nhị phân thu được là tập hợp các số dư của các phép chia.

#include <bits/stdc++.h>
using namespace std;
long long n,x;
int main()
{
cin>>n>>x;
cout<<pow(n,x);
return 0;
}

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.

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.

Yêu cầu: Hãy viết chương trình tính tổng số và liệt kê các bóng đèn sáng ở giây thứ T (1 <= T <= 3600), biết rằng ban đầu tất cả các bóng đèn đều tắt

Program HOC24;
var m,i,n: longint;
d1,d2,d3: integer;
function dx(x: longint): boolean;
var j: longint;
s,s1: string;
begin
s1:=''; dx:=false;
str(x,s);
for j:=length(s) downto 1 do
s1:=s1+s[j];
if s=s1 then dx:=true else exit;
end;
function cp(k: longint): boolean;
begin
cp:=false;
if k=sqr(trunc(sqrt(k))) then cp:=true else exit;
end;
begin
write('Nhap M; N: '); readln(m,n);
d1:=0; d2:=0; d3:=0;
if (m<n) and (m>=10) and (n<=100000) then
begin
write('Cac so doi xung la: ');
for i:=m to n do
if dx(i) then
begin
d1:=d1+1;
write(i,' ');
end;
writeln;
writeln('Co ',d1,' so doi xung');
write('Cac so chinh phuong la: ');
for i:=m to n do
if cp(i) then
begin
d2:=d2+1;
write(i,' ');
end;
writeln;
writeln('Co ',d2,' so chinh phuong');
write('Cac so doi xung chinh phuong la: ');
for i:=m to n do
if dx(i) and cp(i) then
begin
d3:=d3+1;
write(i,' ');
end;
writeln;
write('Co ',d3,' so doi xung chinh phuong');
end;
readln
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;
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.