Tuesday, September 07, 2010

[UVa] 11278 - One-Handed Typist

Be careful with the Backslash and Quote signs. You need to C Escape both. Use mappings instead of linear search.


#include <stdio.h>
#define REP(i, a, b) for (i=a ; i<b ; i++)
#define FILE freopen("input.txt","r",stdin)
char *ns = "`1234567890-=qwertyuiop[]\\asdfghjkl;'zxcvbnm,./";
char *nsr = "`123qjlmfp/[]456.orsuyb;=\\789aehtdck-0zx,inwvg'";
char *s = "~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:\"ZXCVBNM<>?";
char *sr = "~!@#QJLMFP?{}$%^>ORSUYB:+|&*(AEHTDCK_)ZX<INWVG\"";

char tab[256];
int main() {

int I, LEN1 = strlen(sr), LEN2 = strlen(nsr);
char ch;

REP(I, 0, LEN1) {
tab[s[I]] = sr[I];
}
REP(I, 0, LEN2) {
tab[ns[I]] = nsr[I];
}

while (scanf("%c",&ch)==1) {

if (ch=='\n') putchar('\n');
else if (ch==' ') putchar(' ');
else {
putchar(tab[ch]);
}

}

return 0;
}

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.

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...