Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
灵异事件....就这代码我看一天了也没有找出一点错来啊,真是灵异事件... 求牛人帮忙. const z: array[1..30] of string = ('.-','-...','-.-.','-..','.', '..-.','--.','....','..','.---', '-.-','.-..','--','-.','---', '.--.','--.-','.-.','...','-', '..-','...-','.--','-..-','-.--', '--..','..--','.-.-','---.','----'); zz: array[1..30] of longint = (2,4,4,3,1,4,3,4,2,4, 3,4,2,2,3,4,4,3,3,1, 3,4,3,4,4,4,4,4,4,4); var i, j, k: longint; temp, ts, s: string; a: array[-10..1000] of longint; n, m: longint; ans: array[1..1000] of string; begin assign(input,'d:/1.txt'); reset(input); assign(output,'d:/2.txt'); rewrite(output); readln(n); for i := 1 to n do begin ans[i] := ''; readln(s); m := length(s); ts := ''; for j := 1 to m do begin case s[j] of 'A'..'Z': k := ord(s[j])-ord('A') + 1; '_': k := 27; ',': k := 28; '.': k := 29; '?': k := 30; end; ts := ts + z[k]; a[j] := zz[k]; end; for j := m downto 1 do begin temp := copy(ts,1,a[j]); delete(ts,1,a[j]); for k := 1 to 30 do if z[k]=temp then break; case k of 1..26: ans[i] := ans[i] + chr(ord('A')+k-1); 27: ans[i] := ans[i] + '_'; 28: ans[i] := ans[i] + ','; 29: ans[i] := ans[i] + '.'; 30: ans[i] := ans[i] + '?'; end; end; end; for i := 1 to n do begin write(i,': '); writeln(ans[i]); end; close(input); close(output); end. Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator