#include <stdio.h> #include <stdlib.h>
int encrypt(int character, char *order);
int main(int argc, char *argv[]) {
? ? //puts(argv); ? ? //printf("sum of command-line arguments = %d\n", sum);
// ? ?int shift = sum % 26; // ? ?if (shift < 0) { // ? ? ? ?shift = 26 + shift; // ? ?}
? ? int character = getchar(); ? ? while (character != EOF) {
? ? ? ? int new_character = encrypt(character, argv); ? ? ? ? putchar(new_character);
? ? ? ? character = getchar(); ? ? }
? ? return 0; }
int encrypt(int character, char *order) {
? ? int shift = 0; ? ? if (character >= 'a' && character <= 'z') { ? ? ? ? ? ? shift = character - 'a'; ? ? ? ? return order[shift]; ? ? } else if (character >= 'A' && character <= 'Z') { ? ? ? ? shift = character - 'A'; ? ? ? ? return order[shift] - 32; ? ? } else { ? ? ? ? return character; ? ? } } ?
|