-
-
Save yohanes/4680db8ee6f27a9d3ce5ea5d35b967cc 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> | |
#include <stdlib.h> | |
#include <string.h> | |
static int is_serial_valid(const char *user, const char *serial) | |
{ | |
int i, total; | |
for (i=0; i < strlen(user); i++) { | |
total += user[i]; | |
} | |
for (i=0; i < strlen(serial); i++) { | |
total += serial[i]; | |
} | |
return (((total + 17)*100057)%1871)==812; | |
} | |
int main(int argc, char *argv[]) | |
{ | |
char *user; | |
char *serial; | |
if (argc<3) { | |
printf("Usage: serial3 <user> <serial>\n"); | |
return 0; | |
} | |
user = argv[1]; | |
serial = argv[2]; | |
if (is_serial_valid(user, serial)) { | |
printf("correct serial\n"); | |
} else { | |
printf("incorrect serial\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment