String flood problem.
1#include <cstdio>2#include <cstring>3#include <cstdlib>4 5 #defineMAXN 1056 7typedefstruct {8 Chars[5];9 Charch;Ten } pattern_t; One A Charline[2][MAXN]; -Pattern_t pat[8]; - intt, N; the - intCompConst void*a,Const void*b) { -pattern_t *p = (pattern_t *) A; -pattern_t *q = (pattern_t *) b; + - returnstrcmp (P->s, q->s); + } A at intMain () { - intm; - intI, J, K; - intv; - - #ifndef Online_judge inFreopen ("data.in","R", stdin); -Freopen ("Data.out","W", stdout); to #endif + -scanf"%d", &t); the while(t--) { *scanf"%d", &m); $ for(i=0; i<8; ++i)Panax Notoginsengscanf"%s%c", Pat[i].s, &pat[i].ch); -scanf"%s", line[0]+1); the +Qsort (Pat,8,sizeof(pattern_t), comp); Aline[0][0] = line[1][0] ='0'; theK =0; +n = strlen (line[0]+1); - while(m--) { $line[k][n+1] =' /'; $printf"%s\n", line[k]+1); -line[k][n+1] ='0'; -j =!K; the for(i=1; i<=n; ++i) { -v = ((line[k][i-1]-'0') <<2) + ((line[k][i]-'0') <<1) + (line[k][i+1]-'0');WuyiLine[j][i] =pat[v].ch; the } -K =J; Wu } - } About $ return 0; -}
"Hdoj" 2526 romantic phone