- /* corvertiseur x en decimal
-
- #include <iostream.h>
-
- auteur:alphaone
-
- But:Il convertit un nombre en décimal
- binaire: 0 , 1
- 1 + 1
- 2
- donc la base du binaire est deux.
- Hexadécimal: 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f
- 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
- 16
- donc la base du binaire est 16.
-
- */
- #include <stdio.h>
- #include <iostream.h>
- #include <stdlib.h>
- int pui(int n , int p)
- {
- int t;
- t=0;
- int r;
- r=1;
- while(t<n)
- {
- t=t+1;
- r=r*p;
- }
- return (r);
- }
- int main()
- {
- int ta[9];
- int b;
- int n;
- float r;
- int e;
- int t;
- cout << "Nombre de chiffre:";
- int defchi;
- cin >> defchi;
- cout << "Nombre:";
- cin >> n;
- e=4;
- while(e>0)
- {
- e=e-1;
- ta[e]=0;
- r=pui(e , defchi);
- t=int(n/r);
- ta[e]=t;
- n=n-ta[e]*r;
- }
- cout << "Nombre converti:";
- int zero;
- zero=0;
- e=4;
- while(e>0)
- {
- e=e-1;
- if(ta[e]!=0)
- zero=1;
- if(zero==1)
- if(ta[e]>9)
- cout << (char)(ta[e]+55);
- else
- cout << ta[e];
- }
- cout << "\n";
- system("PAUSE");
- return 0;
- }
-
/* corvertiseur x en decimal
#include <iostream.h>
auteur:alphaone
But:Il convertit un nombre en décimal
binaire: 0 , 1
1 + 1
2
donc la base du binaire est deux.
Hexadécimal: 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f
1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1
16
donc la base du binaire est 16.
*/
#include <stdio.h>
#include <iostream.h>
#include <stdlib.h>
int pui(int n , int p)
{
int t;
t=0;
int r;
r=1;
while(t<n)
{
t=t+1;
r=r*p;
}
return (r);
}
int main()
{
int ta[9];
int b;
int n;
float r;
int e;
int t;
cout << "Nombre de chiffre:";
int defchi;
cin >> defchi;
cout << "Nombre:";
cin >> n;
e=4;
while(e>0)
{
e=e-1;
ta[e]=0;
r=pui(e , defchi);
t=int(n/r);
ta[e]=t;
n=n-ta[e]*r;
}
cout << "Nombre converti:";
int zero;
zero=0;
e=4;
while(e>0)
{
e=e-1;
if(ta[e]!=0)
zero=1;
if(zero==1)
if(ta[e]>9)
cout << (char)(ta[e]+55);
else
cout << ta[e];
}
cout << "\n";
system("PAUSE");
return 0;
}