Developpement/23DEV1.1/CM2/Suite.c

37 lines
573 B
C

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int Suite(long val){
long tab[100];
int valor;
int i = 0;
for(i = 0; i<100; i++){
if(i == 0){
valor = val;
}
else{
valor = tab[i-1]/2;
}
tab[i] = valor;
if(i == 0){
printf("%d,", tab[i]);
}else if(tab[i]%2!=0){
printf("%d.", tab[i]);
break;
}else{
printf("%d,", tab[i]);
}
}
}
int main(int argc, char const *argv[])
{
if(argc<2){
printf("Erreur ! L'usage est : %s <entier> ", argv[0]);
}
long val;
val = strtol(argv[1],NULL,10);
Suite(val);
return EXIT_SUCCESS;
}