35 lines
619 B
C
35 lines
619 B
C
/* Code PIN */
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#define CODE "1928"
|
|
|
|
int verifier_code(char*);
|
|
|
|
int main() {
|
|
char pin[4];
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
printf("Code PIN : ");
|
|
scanf("%s", &pin);
|
|
if (verifier_code(pin)) {
|
|
break;
|
|
} else {
|
|
printf("Il reste %d tentatives\n", 2 - i);
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
int verifier_code(char* pin) {
|
|
if (strcmp(pin, CODE) == 0) {
|
|
printf("Téléphone dévérouillé\n");
|
|
return 1;
|
|
} else {
|
|
printf("Erreur, mauvais code\n");
|
|
return 0;
|
|
}
|
|
}
|