Created
October 19, 2015 15:42
-
-
Save antonva/fdfbc9e97cce8bb7304b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void init_input(int input[], size_t psize) { | |
for (size_t i = 0; i < psize; i++) { | |
input[i] = 99; | |
} | |
} | |
int check_password(int *password, size_t psize, int *input) { | |
for (size_t i = 0; i < psize; i++) { | |
printf("%i | ", i); | |
printf("%i, %i\n", password[i], input[i]); | |
if (input[i] > 9) { return -2; } //Means that the input isn't long enough. | |
if (password[i] != input[i]) { return -1; } // No need to check more digits. | |
} | |
return 1; | |
} | |
int main() { | |
size_t psize = 4; | |
int password[] = {1,3,3,7}; | |
int input[4]; | |
init_input(input, psize); | |
input[0] = 1; | |
input[1] = 3; | |
input[2] = 3; | |
input[3] = 7; // This would be your keypad input. Try fucking around with it. | |
int val = check_password(&password, psize, &input); | |
printf("%i\n", val); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment