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~~受打击

Posted by dhu_try at 2009-04-06 20:26:06 on Problem 1051
In Reply To:小女初来乍到,本地没问题,但是WA~~受打击 Posted by:wentingzhao at 2009-04-03 23:59:59
> #include <iostream>
> #include <cstring>
> using namespace std;
> int main()
> {
>     char morse[30][5]={".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","...","-","..-","...-",".--","-..-","-.--","--..","..--",".-.-","---.","----"};
> 	char str[101],mor[401],cmp[5],*p;
> 	int num[100],id[30]={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 n,l,i,j,k,t;
> 	while(cin>>n)
> 	{
> 		getchar();
> 		for(k=1;k<=n;k++)
> 		{
> 			cin.getline(str,100);
> 			l=strlen(str);
> 			mor[0]='\0';
> 			for(i=0;i<l;i++)
> 			{
> 				if(str[i]>='A'&&str[i]<='Z')
> 				{
> 					t=str[i]-65;
> 					strcat(mor,morse[t]);
> 					num[l-1-i]=id[t];
> 				}
> 				else if(str[i]=='_')
> 				{
> 					strcat(mor,morse[26]);
> 					num[l-1-i]=id[26];
> 				}
> 				else if(str[i]==',')
> 				{
> 					strcat(mor,morse[27]);
> 					num[l-1-i]=id[27];
> 				}
> 				else if(str[i]=='.')
> 				{
> 					strcat(mor,morse[28]);
> 					num[l-1-i]=id[28];
> 				}
> 				else
> 				{
> 					strcat(mor,morse[29]);
> 					num[l-1-i]=id[29];
> 				}
> 			}
> 			p=mor;
> 			cout<<k<<": ";
> 			for(i=0;i<l;i++)
> 			{
> 				strncpy(cmp,p,num[i]);
> 				cmp[num[i]]='\0';
> 				p+=num[i];
> 				for(j=0;j<30;j++)
> 				{
> 					if(strcmp(cmp,morse[j])==0)
> 					{
> 						if(j>=0&&j<=25)
> 							cout<<(char)(j+65);
> 						else if(j==26)
> 							cout<<"_";
> 						else if(j==27)
> 							cout<<",";
> 						else if(j==28)
> 							cout<<".";
> 						else
> 							cout<<"?";
> 						break;
> 					}
> 				}
> 			}
> 			cout<<endl;
> 		}
> 	}
> 	return 0;
> }

呵呵~~怎么婷婷也来pku上做题啊??确实不容易呀!
这题大概是打两张表 + 暴力吧.有问题可以找我的嘛

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