1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| #include <stdio.h>
#include <stdlib.h>
//Pour verifier si la proposition est valide et attribuer le score
void validation(char propo1, char propo2){
int score1 = 0,score2 = 0;char chaine[4069980] = "";
int longpropo1 = 0,longpropo2 = 0;
FILE* fichier;
fichier = fopen("dicotionnaire.txt", "r");
if (fichier != NULL){
int i = 0;
while(fgets(chaine, 4069980, fichier) != NULL){
if(strcmp(chaine,propo1)){
longpropo1 = strlen(propo1);
if(longpropo1<2){
score1 = 1;
}
else if(longpropo1<4){
score1 = 5;
}
else if(longpropo1<7){
score1 = 10;
}
else if(longpropo1<10){
score1 = 15;
}
printf("%d", score1);
}
else {
printf("%d", score1);
}
if(strcmp(chaine,propo2)){
longpropo2 = strlen(propo2);
if(longpropo2<2){
score2 = 1;
}
else if(longpropo2<4){
score2 = 5;
}
else if(longpropo2<7){
score2 = 10;
}
else if(longpropo2<10){
score2 = 15;
}
printf("%d", score2);
}
else{
printf("%d", score2);
}
i++;
}
}
else{
printf("Impossible d'ouvrir le fichier ");
}
fclose(fichier);
}
int main(){
char p1[9],p2[9];
printf("Entrez P1: ");
scanf("%s",p1);
printf("\nEntrez P2: ");
scanf("%s",p2);
printf(p1);
printf("\n");
printf(p2);
validation(p1,p2);
return 0;
} |
Partager