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 |
帮我看看我的代码.,哪里错了?wa#include <stdio.h> #include <memory.h> const char code[99]=".--...-.-.-.....-.--........----.-.-..---.---.--.--.-.-....-..-...-.---..--.----....------.-.----."; const int cur[31]={0,2,6,10,13,14,18,21,25,27,31,34,38,40,42,45,49,53,56,59,60,63,67,70,74,78,82,86,90,94,98}; #define trans(a) \ memcpy(&s2[p2],&code[a],4); \ p2+=4; \ p[p1++]=4; \ continue; #define set(a) \ s1[p3++]=a;\ p2+=4;\ continue; void main() { int t,tt; char s1[100],s2[400]; int p[100],p1=0,p2=0,p3=0,c=0; scanf("%d",&t); tt=t; while(t>=0&&t--) { p1=0;p2=0;p3=0; scanf("%s",s1); while(s1[p3++]!='\0') { if(s1[p3-1]=='_') {trans(82);} if(s1[p3-1]=='?') {trans(86);} if(s1[p3-1]==',') {trans(90);} if(s1[p3-1]=='.') {trans(94);} p[p1++]=cur[s1[p3-1]-64]-cur[s1[p3-1]-65]; memcpy(&s2[p2],&code[cur[s1[p3-1]-65]],p[p1-1]); p2+=p[p1-1]; } p2=0;p3=0; while(--p1>=0) { c=0; while(c++<=30) { if(cur[c]-cur[c-1]==p[p1]&&memcmp(&code[cur[c-1]],&s2[p2],p[p1])==0) break; } if(c==27) {set('_');} if(c==28) {set('?');} if(c==29) {set(',');} if(c==30) {set('.');} s1[p3++]=&cur[c-1]-cur+65; p2+=p[p1]; } printf("%d: %s\n",tt-t,s1); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator