Ajout des TP
This commit is contained in:
45
BUT1/DEV1.1/CM2 2022/1/Makefile
Normal file
45
BUT1/DEV1.1/CM2 2022/1/Makefile
Normal 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 ###
|
||||
|
||||
|
||||
|
||||
|
20
BUT1/DEV1.1/CM2 2022/1/programme.c
Normal file
20
BUT1/DEV1.1/CM2 2022/1/programme.c
Normal 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
BIN
BUT1/DEV1.1/CM2 2022/1/repetition
Executable file
Binary file not shown.
12
BUT1/DEV1.1/CM2 2022/1/repetition.c
Normal file
12
BUT1/DEV1.1/CM2 2022/1/repetition.c
Normal 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;
|
||||
}
|
7
BUT1/DEV1.1/CM2 2022/1/repetition.h
Normal file
7
BUT1/DEV1.1/CM2 2022/1/repetition.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef REPETITION_H
|
||||
#define REPETITION_H
|
||||
|
||||
int repetition(long tab[],int taille);
|
||||
|
||||
#endif /* REPETITION_H */
|
||||
|
Reference in New Issue
Block a user