utilisation des fonctions
Bonsoir;
j'utilise dans le même projet plusieurs fichiers sources, chaque fichier contient une fonctions et un autre fichier source qui représente le programme principale "main.c", l'appel de toutes les fonctions se fait au niveau du programme principale, mon but c'est d'importer un fichier, calculer et afficher la distance,
je probleme c'est que l'execution du programme principale n'affiche rien
Code:
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
| main.c
#include <stdio.h>
#include <stdlib.h>
int main(void) {
int i;
int j;
int k;
double f[150][4];
double dis[150][150]={0};
if(!readIris(f)) {
puts("....");
//readIris(f);
computeDistance(dis,f);
//printf("aaa");
system("PAUSE");
return(1);
}
//return 0;
} |
Code:
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
| readIris.c
#include <math.h>
#include <stdio.h>
#include <stdbool.h>
bool readIris(double f[][4]) {
FILE *st;
int i;
int j;
int k;
st=fopen("ir.csv","r");
if(!st)
return(0);
for(i=0;i<150;i++)
for(j=0;j<4;j++)
fscanf(st,"%lf;",&f[i][j]);
//printf("f=%f",f[1][1]);
fclose(st);
for(i=0;i<150;i++, puts(""))
for(j=0;j<4;j++)
printf("%g ",f[i][j]);
return(1);
//system("PAUSE");
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| computeDistance.c
#include <math.h>
#include <stdio.h>
#include <stdbool.h>
void computeDistances(double dis[][150],double f[][4]) {
int i;
int j;
int k;
for(i=0;i<150;i++)
for( j=0;j<150;j++) {
double temp=0;
for( k=0;k<4;k++)
temp+=sqrt(pow(f[i][k]-f[j][k],2));
dis[i][j]=temp;
}
//system("PAUSE");
} |