debut TP21

This commit is contained in:
2023-11-28 17:25:17 +01:00
parent d64b38f93d
commit c4bc163fe6
13 changed files with 130 additions and 0 deletions

BIN
DEV1.1/TP20/challenger Executable file

Binary file not shown.

25
DEV1.1/TP20/challenger.c Normal file
View File

@@ -0,0 +1,25 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv){
int score,score_prec,i,chal_score;
char nom[3];
chal_score=strtol(argv[1],NULL,10);
FILE* file;
file=fopen("top10","r");
if (file==NULL){
printf("mauvaise ouverture");
return EXIT_FAILURE;
}
printf("|Hall of Fame|\n");
for (i=0;i<10;i++){
fread(&score,sizeof(int),1,file);
fread(nom,sizeof(char),3,file);
if (chal_score>score && chal_score<score_prec)
printf("%09d %s\n",chal_score,argv[2]);
printf("%09d %s\n",score,nom);
score_prec=score;
}
fclose(file);
return EXIT_SUCCESS;
}

BIN
DEV1.1/TP20/records Executable file

Binary file not shown.

21
DEV1.1/TP20/records.c Normal file
View File

@@ -0,0 +1,21 @@
#include <stdio.h>
#include <stdlib.h>
int main(void){
int score,i;
char nom[3];
FILE* file;
file=fopen("top10","r");
if (file==NULL){
printf("mauvaise ouverture");
return EXIT_FAILURE;
}
printf("|Hall of Fame|\n");
for (i=0;i<10;i++){
fread(&score,4,1,file);
fread(&nom,3,1,file);
printf("%09d %s\n",score,nom);
}
fclose(file);
return EXIT_SUCCESS;
}

BIN
DEV1.1/TP20/top10 Normal file

Binary file not shown.