题解 | #字符串加密#
字符串加密
http://www.nowcoder.com/practice/e4af1fe682b54459b2a211df91a91cf3
#include <stdio.h>
#include <string.h>
static char g_string[2][101] = {0};
int main(int argc, char** argv)
{
scanf("%s%s", g_string[0], g_string[1]);
int len = strlen(g_string[0]);
for (int i = 0; i < len; i++) {
for (int j = i + 1; j < len; j++) {
if (g_string[0][i] != g_string[0][j]) continue;
for (int k = j; k < len; k++) g_string[0][k] = g_string[0][k + 1];
len--; j--;
}
}
for (int i = 'a'; i <= 'z'; i++) if (strchr(g_string[0], i) == NULL) g_string[0][len++] = i;
for (int i = 0; i < strlen(g_string[1]); i++) g_string[1][i] = g_string[0][g_string[1][i] - 'a'];
printf("%s\n", g_string[1]);
return 0;
}