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,45 @@
### VARIABLES ###
CC = gcc
CFLAGS = -ansi \
-pedantic
EXE = repetition_dans_tableaux
OFILES = main.o \
repetition.o
### BUT PAR DEFAUT ###
but : ${EXE}
### REGLES ESSENTIELLES ###
programme : repetition.o main.o
$(CC) $(CFLAGS) -o programme repetition.o main.o
repetition.o : repetition.c repetition.h
$(CC) $(CFLAGS) -c repetition.c
main.o : main.c repetition.h
$(CC) $(CFLAGS) -c main.c
${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,20 @@
#include <stdlib.h>
#include <stdio.h>
#include "repetition.h"
int main(int argc, char* argv[]){
int i;
long* tab;
tab = (long*) malloc(argc*sizeof(long));
for(i=1;i<argc;i++){
tab[i-1] = strtol(argv[i],NULL,10);
}
if(repetition(tab,argc-1)==0){
printf("Les valeurs sont différentes\n");
}else{
printf("Les valeurs sont identiques\n");
}
return EXIT_SUCCESS;
}

BIN
BUT1/DEV1.1/CM2 2022/1/repetition Executable file

Binary file not shown.

View File

@@ -0,0 +1,12 @@
#include <stdlib.h>
#include <stdio.h>
int repetition(long tab[],int taille){
int i;
for(i=0;i<taille-1;i++){
if(tab[i]!=tab[i+1]){
return 0;
}
}
return 1;
}

View File

@@ -0,0 +1,7 @@
#ifndef REPETITION_H
#define REPETITION_H
int repetition(long tab[],int taille);
#endif /* REPETITION_H */