Code Sample |
#include <stdio.h> #define MAX 4 int check (char *s) { printf ("%s\n", s); if (!strcmp (s, "help")) return (1); return (0); } //-------------------------------------- char s[MAX+1]; int try_again (int pos) { char c; s[pos+1]='\0'; for (c='a'; c<'z'+1; c++) { s[pos] = c; if (check (s)) return(1); //success! if (pos == MAX-1) continue; if (try_again (pos+1)) return(1); } return (0); } //-------------------------------------- int main () { if (try_again (0)) printf ("cracked :)\n"); else printf ("failed :(\n"); } |