mirror of
https://codeberg.org/DansLeRuSH/c-plus-plus-exercises.git
synced 2024-11-21 19:18:08 +00:00
32 lines
461 B
C++
32 lines
461 B
C++
|
// Auteur : ALBARET Franck
|
||
|
#include <conio.h>
|
||
|
#include <stdio.h>
|
||
|
|
||
|
int main(void)
|
||
|
{
|
||
|
clrscr();
|
||
|
int res=0;
|
||
|
int puis [9];
|
||
|
char bin [9];
|
||
|
int x,y;
|
||
|
puts ("Entrer une valeur binaire (1 octet) :");
|
||
|
gets (bin);
|
||
|
puis[1]=1;
|
||
|
for (x=2;x<9;x++)
|
||
|
{
|
||
|
puis[x]=2*puis[x-1];
|
||
|
}
|
||
|
y=7;
|
||
|
for (x=1;x<9;x++)
|
||
|
{
|
||
|
if (bin[y]=='1')
|
||
|
{
|
||
|
res=res+puis[x];
|
||
|
}
|
||
|
y--;
|
||
|
}
|
||
|
printf("%i",res);
|
||
|
getch();
|
||
|
return 0;
|
||
|
}
|