示例输入输出:(有关莫斯电码部分请自行百度)
1 #include<bits/stdc++.h> 2 using namespace std; 3 int main() 4 { 5 string s[]= {"*-","-***","-*-*","-**","*","**-*","--*","****","**","*---","-*-","*-**","--","-*","---","*--*","--*-","*-*","***","-","**-","***-","*--","-**-","-*--","--**"}; 6 string s1; 7 while(cin>>s1) 8 { 9 for(int i=0; i<s1.length(); i++) 10 if(s1[i]==‘|‘)s1[i]=‘ ‘; 11 string a; 12 for(istringstream sin(s1); sin>>a;) 13 { 14 for(int i=0; i<26; i++) 15 { 16 if(a==s[i])printf("%c",i+97); 17 } 18 } 19 cout<<endl; 20 } 21 return 0; 22 }
原文:http://www.cnblogs.com/A--Q/p/6294799.html