59 lines
1.1 KiB
C
59 lines
1.1 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
int main(void){
|
|
FILE* fichier;
|
|
fichier = fopen("top10", "r");
|
|
int tab[10];
|
|
char oui[30];
|
|
int i;
|
|
int a;
|
|
int alt = 4;
|
|
for(i=0; i<10; i++){
|
|
fread(&tab[i], sizeof(int), 1,fichier);
|
|
fread(&oui[i*3], 1, 3, fichier);
|
|
}
|
|
for(i=0; i<10;i++){
|
|
printf("%9d ", tab[i]);
|
|
printf("%c", oui[i*3]);
|
|
printf("%c", oui[i*3+1]);
|
|
printf("%c\n", oui[i*3+2]);
|
|
}
|
|
fclose(fichier);
|
|
int score;
|
|
char pseudo;
|
|
int emplacement;
|
|
printf("Donnez un score : ");
|
|
scanf("%7d", &score);
|
|
printf("Donnez un pseudo : ");
|
|
scanf("%c", &pseudo);
|
|
if(strlen(pseudo) != 3){
|
|
scanf("%c", &pseudo);
|
|
}
|
|
|
|
for(i=0; i<10; i++){
|
|
if (score > tab[i]){
|
|
emplacement = i;
|
|
i =10;
|
|
}
|
|
}
|
|
for(i=10; i>=emplacement; i--){
|
|
tab[i] == tab[i]+1;
|
|
}
|
|
tab[emplacement] = score;
|
|
emplacement = emplacement+3;
|
|
for(i=30; i<= emplacement; i--){
|
|
oui[i] == oui[i+3];
|
|
}
|
|
for(i=0; i<3; i++){
|
|
oui[emplacement] == pseudo[i];
|
|
emplacement++;
|
|
}
|
|
printf("%d",tab);
|
|
printf("%c", oui);
|
|
return EXIT_SUCCESS;
|
|
}
|
|
/*[004867123,41545574]
|
|
[B,O,B,<,O,>]
|
|
004867123 BOB
|
|
41545574 <O>*/ |