Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:请教下,WA了2小时了。。。

Posted by ecjtuFFF at 2008-11-26 19:50:02 on Problem 1051
In Reply To:请教下,WA了2小时了。。。 Posted by:hzp181367405 at 2008-11-05 23:13:54
> #include "stdio.h"
> #include "string.h"
> char push(char *str,char *s);
> char out(char *str,int t);	
> char search(char *s);
> char p[100][10]={".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--..","..--",".-.-","---.","----"};
> int main()
> {
> 	int i,j,k,n,len,sum,test=0;
> 	char s[150],str[800],c;
> 	int hh[100]={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};
> 	int num[110];
> 	scanf("%d%c",&n,&c);
> 		for ( i=1 ; i<=n ; i++ )
> 		{
> 			gets(s);
> 			len=strlen(s);
> 			for ( j=0 ; j<len ; j++ )
> 				if ( s[j]>='A' && s[j]<='Z' )
> 					num[j]=hh[s[j]-'A'];
> 				else
> 					num[j]=4;
> 			sum=0;
> 			str[0]=0;
> 			for ( j=0 ; j<len ; j++ )
> 			{
> 				if ( s[j]>='A' && s[j]<='Z' )
> 					push(str,p[s[j]-'A']);
> 				else if ( s[j]=='_' )
> 					push(str,p[26]);
> 				else if ( s[j]==',' )
> 					push(str,p[27]);
> 				else if ( s[j]=='.' )
> 					push(str,p[28]);
> 				else if ( s[j]=='?' )
> 					push(str,p[29]);
> 			}
> 			for ( j=0 ; j<len/2 ; j++ )
> 			{c=num[j];num[j]=num[len-j-1];num[len-j-1]=c;}
> 			str[0]=0;
> 			printf("%d: ",++test);
> 			for ( j=0 ; j<len ; j++ )
> 				out(str,num[j]);
> 			printf("\n");
> 		}
> 	return 0;
> }
> char push(char *str,char *s)
> {
> 	int len=strlen(s);
> 	for ( int i=0 ; i<len ; i++ )
> 		str[++str[0]]=s[i];
> 	return *str;
> }
> char out(char *str,int t)
> {
> 	char ss[10];
> 	for ( int i=0 ; i<t ; i++ )
> 		ss[i]=str[++str[0]];
> 	ss[t]=0;
> 	char c=search(ss);
> 	if ( c=='Z'+1 )
> 		printf("_");
> 	else if ( c=='Z'+2 )
> 		printf(",");
> 	else if ( c=='Z'+3 )
> 		printf(".");
> 	else if ( c=='Z'+4 )
> 		printf("?");
> 	else
> 		printf("%c",c);
> 	return *str;
> }
> char search(char *s)
> {
> 	for ( int i=0 ; i<30 ; i++ )
> 		if (strcmp(p[i],s)==0)
> 			return i+'A';
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator