Last active
October 19, 2015 15:58
-
-
Save antonva/25ecd878762cc0cf3526 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++) { | |
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]; | |
while(1) { | |
init_input(input, psize); | |
// This would be your keypad input. Try fucking around with it. | |
scanf("%i", &input[0]); | |
scanf("%i", &input[1]); | |
scanf("%i", &input[2]); | |
scanf("%i", &input[3]); | |
int val = check_password(password, psize, input); | |
if ( val == 1 ) { printf("A-access granted anona-senpai.\n"); } | |
else { printf("B-baka, you're not anona-kun!\n"); } | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment