#include <stdio.h>
#include <stdlib.h>
char tab[10000];
int main() {
char demo[100], ch, input[1000], plain[200];
int i, t;
scanf("%d",&t);
getchar();
gets(demo);
while (t--) {
for (i=0 ; i<200 ; i++) {
tab[i]=0;
}
gets(plain);
i=0;
while ((ch=getchar())!='\n') {
tab[plain[i++]] = ch;
putchar(ch);
}
putchar('\n');
puts(plain);
while (gets(input)) {
if (!strcmp(input,""))
break;
else {
for (i=0 ; input[i]!='\0' ; i++) {
if (tab[input[i]])
putchar(tab[input[i]]);
else
putchar(input[i]);
}
}
printf("\n");
}
if (t) printf("\n");
}
return 0;
}
Monday, September 06, 2010
[UVa] 865 - Substitution Cypher
All you need is a table, and because it's such a small limit of possible letters, all you need is a hardly 150-200 sized array in which you can directly map the letters rather than search for them. Helps you access them in 0(1).
Subscribe to:
Post Comments (Atom)
Connect Rapoo MT750S with Linux (Tested on Manjaro)
I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...
-
I like coding a lot, keeps me glued to the PC for hours. For that reason it's a need to edit the Syntax Highlighter to suit my eyes for...
-
I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...
-
Install MinGW GCC Port on Windows. 1. Just go to this address [ http://sourceforge.net/projects/mingw/files/Installer/mingw-get-inst/ ]...
No comments:
Post a Comment
Post your comment here. If you want to say something about programming problems, scripts, software etc, please try to be as descriptive as possible.