Ajout des TP

This commit is contained in:
stiti
2024-02-01 13:55:03 +01:00
parent 4fe273c309
commit 113583b37a
228 changed files with 7094 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
### VARIABLES ###
CC = gcc
CFLAGS = -ansi \
-pedantic
EXE = valeurs_nulles
OFILES = recherche.o \
main.o
### BUT PAR DEFAUT ###
but : ${EXE}
### REGLES ESSENTIELLES ###
recherche.o : recherche.c
main.o : main.c recherche.h
${EXE} : ${OFILES}
$(CC) $(CFLAGS) -o ${EXE} ${OFILES}
### REGLES OPTIONNELLES ###
clean :
-rm -f ${OFILES}
mrproper : clean but
### BUTS FACTICES ###
.PHONY : but clean mrproper
### FIN ###

View File

@@ -0,0 +1,15 @@
#include <stdlib.h>
#include <stdio.h>
#include "recherche.h"
int main(int argc, char* argv[]){ /* ou char** */
int i;
double* tab;
tab = (double*) malloc(argc*sizeof(double));
for(i=0;i<argc-1;i++){
tab[i] = strtod(argv[i+1],NULL);
}
printf("%d valeurs nulles\n",recherche(tab,argc-1));
}

View File

@@ -0,0 +1,13 @@
#include <stdlib.h>
#include <stdio.h>
int recherche(double tab[], int taille){
int valeurs_null = 0, i;
for(i=0;i<taille;i++){
if(tab[i]==0){
valeurs_null++;
}
}
return valeurs_null;
}

View File

@@ -0,0 +1,6 @@
#ifndef RECHERCHE_H
#define RECHERCHE_h
int recherche(double tab[], int taille);
#endif /* RECHERCHE_H */

Binary file not shown.