Tfe

Ongi etorri tfe-ren webgunera...

Old stuff/ecole_etude_fac_de_pau/nico/calc/old.cc

(Deskargatu)
#include<iostream.h>

void conversion(int i)
{int tab[8]={0,0,0,0,0,0,0,0};
 int cpt=0;
 while(i>1)
   {tab[cpt]=(i%2);
   cpt++;
   i=i/2;
   }
 tab[cpt]=i;
 for(int j=7;j>=0;j--)
   cout<<tab[j];
}



main(){
  int f;
  cout<<"Entrez le nombre a convertir:";
  cin>>f;
  conversion(f);
  cout<<'\n';
  cout<<'\n';
  unsigned char *ptr;
  ptr=(unsigned char*) &f;
  conversion(*ptr);
  cout<<'\n';
  conversion(*(ptr+1));
  cout<<'\n';
  conversion(*(ptr+2));
  cout<<'\n';
  conversion(*(ptr+3));
  cout<<'\n';
}