Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <cs50.h>
- #include <string.h>
- int main(void)
- {
- //first set (A - z)
- char password[5] = {'A', '\0', '\0', '\0', '\0'};
- while (password[0] <= 'z')
- {
- printf("%s\n", password);
- password[0]++;
- if (password[0] == 91)
- {
- password[0] = 97;
- }
- }
- //second set, (AA - zz)
- password[0] = 'A';
- password[1] = 'A';
- while (password[0] <= 'z' && password[1] <= 'z')
- {
- printf("%s\n", password);
- //iterate second char
- if (password[1] != 'z')
- {
- password[1]++;
- if (password[1] == 91)
- {
- password[1] = 97;
- }
- }
- //if second char is 'z' then set back to 'A' and iterate first char
- else
- {
- password[1] = 'A';
- password[0]++;
- if (password[0] == 91)
- {
- password[0] = 97;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement