Skip to content

Instantly share code, notes, and snippets.

@jy95
Last active September 22, 2015 18:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jy95/07146424ddeb277a6345 to your computer and use it in GitHub Desktop.
Save jy95/07146424ddeb277a6345 to your computer and use it in GitHub Desktop.
/* Version 2 */
int n;
int main(){
int nombre;
int unite;
double 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 ((unite = getchar()) >= '0' && unite <= '9' ) {
if (getchar() == '\n') {
nombre=nombre-'0';
unite = unite - '0';
if (nombre >= 0 && nombre < 10 && unite >= 0 && unite < 10 ) {
nombre = (nombre * 10 ) + unite;
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