Last active
September 21, 2015 21:03
-
-
Save jy95/676cea3c8ebeaa45a2b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
#include<limits.h> | |
/*Version 1 - Nombre à un chiffre*/ | |
int n; | |
int main(){ | |
int nombre; | |
int factorielle; | |
while((nombre=getchar()) != EOF ){ | |
if (nombre == '\n') { | |
printf("Ligne vide \n"); | |
continue; | |
} | |
if ( nombre < '0' || nombre > '9'){ | |
printf("Pas un chiffre \n"); | |
while(getchar() != '\n'){ | |
} | |
continue; | |
} | |
if (getchar() == '\n') { | |
nombre=nombre-'0'; | |
if (nombre >= 0 && nombre < 10) { | |
factorielle = 1; | |
for(;nombre > 0;nombre--){ | |
factorielle*=nombre; | |
} | |
printf("resultat %d \n",factorielle); | |
continue; | |
} | |
while(getchar() != '\n') { | |
} | |
continue; | |
} | |
return 0; | |
} | |
} | |
/* Version 2 | |
* | |
int n; | |
int main(){ | |
int nombre; | |
int factorielle; | |
while((nombre=getchar()) != EOF ){ | |
if (nombre == '\n') { | |
printf("Ligne vide \n"); | |
continue; | |
} | |
if ( nombre < '0' || nombre > '9'){ | |
printf("Pas un chiffre \n"); | |
while(getchar() != '\n'){ | |
} | |
continue; | |
} | |
if (getchar() == '\n') { | |
nombre=nombre-'0'; | |
if (nombre >= 0 && nombre < 10) { | |
factorielle = 1; | |
for(;nombre > 0;nombre--){ | |
factorielle*=nombre; | |
} | |
printf("resultat %d \n",factorielle); | |
continue; | |
} | |
while(getchar() != '\n') { | |
} | |
continue; | |
} | |
return 0; | |
} | |
} | |
* */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment