Skip to content

Instantly share code, notes, and snippets.

@ydm
Created August 24, 2023 12:58
Show Gist options
  • Select an option

  • Save ydm/75f8acbc51ca953a2c9bf77700302d3c to your computer and use it in GitHub Desktop.

Select an option

Save ydm/75f8acbc51ca953a2c9bf77700302d3c to your computer and use it in GitHub Desktop.
#include <stdio.h>
int find_index(char s[], char element)
{
int i;
for (i = 0; s[i] != '\0'; i++)
{
if (s[i] == element)
{
return i;
}
}
return -1;
}
int main()
{
char c;
char plain[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
char cipher[] = "fAOjrhNKknMpIivUGmPxlQDeCTFJyt RLSWsdEXcYoawqZzbBugVH";
while ((c = getchar()) != EOF)
{
int i = find_index(cipher, c);
if (i >= 0)
{
putchar(plain[i]);
}
else
{
putchar(c);
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment