39 lines
718 B
C
39 lines
718 B
C
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
|
||
|
int* suite(int entier){
|
||
|
int i = 0, result = entier, nombre_operation;
|
||
|
int* tab;
|
||
|
|
||
|
for (nombre_operation = 0; (result % 2) != 0; i++){
|
||
|
result = result / 2;
|
||
|
}
|
||
|
|
||
|
tab = (int*) malloc(nombre_operation * sizeof(int));
|
||
|
tab[0] = entier;
|
||
|
|
||
|
for (i = 1; (entier % 2) != 0; i++){
|
||
|
entier = entier / 2;
|
||
|
tab[i] = entier;
|
||
|
printf("%d", tab[i]);
|
||
|
}
|
||
|
|
||
|
return tab;
|
||
|
}
|
||
|
|
||
|
int main(void){
|
||
|
int i;
|
||
|
int* tab1 = suite(5);
|
||
|
int* tab2 = suite(6);
|
||
|
int* tab3 = suite(7);
|
||
|
|
||
|
for(i=0;i<10;i++){
|
||
|
printf("%d\n",tab1[i]);
|
||
|
}
|
||
|
|
||
|
free(tab1);
|
||
|
free(tab2);
|
||
|
free(tab3);
|
||
|
|
||
|
return EXIT_SUCCESS;
|
||
|
}
|