1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| #include <stdio.h>
#include <stdlib.h>
// Prototype de la fonction
int fonction_heaviside(double x);
// Main
int main(int argc, char *argv[])
{
double somme_ponderee = 0;
scanf("%d", somme_ponderee); // On demande d'entrer l'age avec scanf
if(argc != 6)
{
printf("Utilisation : ./neurone seuil valeur_1 poid_synaptique_1 valeur_2 poid_synaptique_2\n");
return 1;
}
somme_ponderee = atof(argv[2]) * atof(argv[3]) + atof(argv[4]) * atof(argv[5]) - atof(argv[1]);
printf("Résultat: %d\n", fonction_heaviside(somme_ponderee));
return 0;
}
// Définition de la fonction
int fonction_heaviside(double x)
{
if(x < 0)
return 0;
else
return 1;
} |
Partager