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:好无聊的题,贴个代码

Posted by snowdreams11 at 2012-04-24 18:10:36 on Problem 1051
In Reply To:好无聊的题,贴个代码 Posted by:speedcell4 at 2012-04-24 11:10:03
> string toMorse(char n)
> {
> 	switch(n)
> 	{
> 		case 'A':
> 			return ".-";
> 		case 'B':
> 			return "-...";
> 		case 'C':
> 			return "-.-.";
> 		case 'D':
> 			return "-..";
> 		case 'E':
> 			return ".";
> 		case 'F':
> 			return "..-.";
> 		case 'G':
> 			return "--.";
> 		case 'H':
> 			return "....";
> 		case 'I':
> 			return "..";
> 		case 'J':
> 			return ".---";
> 		case 'K':
> 			return "-.-";
> 		case 'L':
> 			return ".-..";
> 		case 'M':
> 			return "--";
> 		case 'N':
> 			return "-.";
> 		case 'O':
> 			return "---";
> 		case 'P':
> 			return ".--.";
> 		case 'Q':
> 			return "--.-";
> 		case 'R':
> 			return ".-.";
> 		case 'S':
> 			return "...";
> 		case 'T':
> 			return "-";
> 		case 'U':
> 			return "..-";
> 		case 'V':
> 			return "...-";
> 		case 'W':
> 			return ".--";
> 		case 'X':
> 			return "-..-";
> 		case 'Y':
> 			return "-.--";
> 		case 'Z':
> 			return "--..";
> 		case '_':
> 			return "..--";
> 		case ',':
> 			return ".-.-";
> 		case '.':
> 			return "---.";
> 		case '?':
> 			return "----";
> 	}
> }
> char toLetter(string n)
> {
> 	if(n==".-")
> 		return 'A';
> 	else if(n=="-...")
> 		return 'B';
> 	else if(n=="-.-.")
> 		return 'C';
> 	else if(n=="-..")
> 		return 'D';
> 	else if(n==".")
> 		return 'E';
> 	else if(n=="..-.")
> 		return 'F';
> 	else if(n=="--.")
> 		return 'G';
> 	else if(n=="....")
> 		return 'H';
> 	else if(n=="..")
> 		return 'I';
> 	else if(n==".---")
> 		return 'J';
> 	else if(n=="-.-")
> 		return 'K';
> 	else if(n==".-..")
> 		return 'L';
> 	else if(n=="--")
> 		return 'M';
> 	else if(n=="-.")
> 		return 'N';
> 	else if(n=="---")
> 		return 'O';
> 	else if(n==".--.")
> 		return 'P';
> 	else if(n=="--.-")
> 		return 'Q';
> 	else if(n==".-.")
> 		return 'R';
> 	else if(n=="...")
> 		return 'S';
> 	else if(n=="-")
> 		return 'T';
> 	else if(n=="..-")
> 		return 'U';
> 	else if(n=="...-")
> 		return 'V';
> 	else if(n==".--")
> 		return 'W';
> 	else if(n=="-..-")
> 		return 'X';
> 	else if(n=="-.--")
> 		return 'Y';
> 	else if(n=="--..")
> 		return 'Z';
> 	else if(n=="..--")
> 		return '_';
> 	else if(n==".-.-")
> 		return ',';
> 	else if(n=="---.")
> 		return '.';
> 	else if(n=="----") 
>         return '?';
> }
> 
> string a,b;
> int tcase,times=1;
> 
> int main()
> {
> 	cin>>tcase;
> 	while(tcase--)
> 	{
> 		b="";
> 		cin>>a;
> 		for(int i=0;a.length()>i;i++)
> 		{
> 			b+=toMorse(a[i]);
> 		}
> 		cout<<times++<<": ";
> 		for(int j=0,i=a.length()-1;i>=0;i--)
> 		{
> 			cout<<toLetter(b.substr(j,toMorse(a[i]).length()));
> 			j+=toMorse(a[i]).length();
> 		}
> 		cout<<endl;
> 	}
> 	return 0;
> }

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