Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string key = argv[1];
- for (int i = 0, k = strlen(key); i < k; i++)
- {
- if (isdigit(key[i]))
- {
- printf("Please give an alphabetical keyn");
- return 1;
- }
- }
- string plain = GetString ();
- int j = 0;
- int plainn = strlen(plain);
- for (int i = 0; i < plainn; i++)
- {
- if (j>=(strlen(argv[1])))
- {
- j = 0;
- }
- if (islower(key[j]))
- {
- key[j] = key[j] - 97;
- }
- else if (isupper(key[j]))
- {
- key[j] = key[j] - 65;
- }
- if (isalpha(plain[i]))
- {
- if (islower(plain[i]))
- {
- printf("%c", (((( plain[i]-'a')+(key[j++]))%26)+'a'));
- }
- else
- {
- printf("%c", (((( plain[i]-'A')+(key[j++]))%26)+'A'));
- }
- }
- else
- {
- printf("%c", plain[i]);
- }
- }
- printf("n");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement