1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main(void)
{
int i,j,k,x;
int resultat[17];
k=0;
printf("entrer un octal :");
scanf("%o",&i);
j=(int)i;
printf("\nconversion decimal :%d",j);
while (j!=1)
{
if (j%2==0 && j!=2)
{
resultat[k]=0;
k=k+1;
j=j/2;
}
else
{
resultat[k]=1;
k=k+1;
j=j-1;
}
}
for(x=k;x<17;x++)
{
resultat[x]=0;
}
for(x=0;x<17;x++)
{
printf("\nresultat:%d",resultat[x]);
}
getchar();
return 0;
} |
Partager