Răspunsuri

2014-09-19T22:06:25+03:00
Asta inseamna sa transformi un numar din baza 10 in baza 2.
Mai jos este scris in C++. Sper ca intelegi :).

#include<iostream.h>
void main()
{
long n,n1,b,aux,nr;
aux=nr=0;
cout<<"n=";cin>>n;
cout<<"b=";cin>>b;
n1=n;
do
{
aux=aux*10+n1%b;
n1=n1/b;
}
while(n1!=0);
cout<<aux<<endl;;
do
{
nr=nr*10+aux%10;
aux=aux/10;
}
while(aux);
cout<<"numarul "<<n<<" in baza "<<b<<" este: "<<nr;
}

Cel mai inteligent răspuns!
2014-09-20T00:02:20+03:00
(N)3 treci in (N)10 apoi in (N)2, unde a^b inseamna a la puterea b
(0)3=0*3 ^0=(0)10; (0)10/2 deci (0)2
(1)3=1*3 ^0==1*1=(1)10; (1)10/2 deci (1)2
(2)3=2*3 ^0=2*1=(2)10; (2)10/2 deci (10)2
(10)3=10*3 ^0=10*1=(10)10; (10)10/2 deci (1010)2
(11)3=11*3 ^0=11*1=(11)10; (11)10/2 deci (1011)2
(12)3=12*3 ^0=12*1=(12)10; (12)10/2 deci (1100)2
2 5 2