Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- Online C Compiler.
- Code, Compile, Run and Debug C program online.
- Write your code in this editor and press "Run" button to compile and execute it.
- *******************************************************************************/
- #include <stdio.h>
- int main()
- {
- string nombr;
- int a,d,i,poid,reinit, nombrefinale;
- int tab[30];
- if(d<a) {
- // muliplier
- // gérer les bases
- if(d == 16) reinit =3;
- else {
- if (d == 8) reinit =2;
- }
- // débuter la programation
- nombrFinale=0;
- poid=0;
- for(i=0; i<=sizeof(nombr) i++) {
- if(d != 10){if(poid == reinit) poid=0;}
- nombrFinale = nombrFinale + nombr[i] * (2^poid);
- poid++;
- }
- printf("%d", nombrFinale);
- }else {
- // diviser
- /* convertir le string en int !*/
- /* debut convertion en binaire*/
- for(i=0; nombr > 0; i++)
- {
- tab[i] = nombr%2;
- nombr = nombr/2;
- }
- printf("\nLe nombre binaire est = ");
- for(i=i-1; i >= 0; i--)
- {
- printf("%d",tab[i]);
- }
- /* fin convertion en binaire*/
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement