"Recursive and recursive" phone number

Source: Internet
Author: User

Question L: "Recursive and recursive" phone number Title DescriptionA number of English letters are written below each number on the telephone. The distribution is as follows:
1~abc
2~def
3~ghi
4~ikl
5~mn
6~opq
7~rst
8~uvw
9~xyz
Now given a word list and a string of numbers, please use the words in the word list to translate this password.

InputThe first behavior a positive integer N indicates the number of words in the Word table (n≤100);
Second act a string of numbers not exceeding 100, indicating the password;
The next n rows, each line of a word with a length of not more than 20, represent the Word table.

Outputonly one line, the translated text, if the password can not be translated, then output "No solutions!", if the password has a variety of translations, the output can be any. Sample input
873373711664thishsthisisbabook
Sample output
Thi Shs b Boo k
#include <bits/stdc++.h>using namespacestd;intn,cnt =1;structWord {strings,l;} a[101];stack<int>STA;stringO;stack<int>p;voidSlove (intYintx) {if(!cnt)return ; if(Y = =o.size ()) {         while(!Q.empty ()) {            intx =P.top ();            Sta.push (x);        P.pop (); }         intx =Sta.top ();            Sta.pop (); cout<<A[x].s;  while(!Sta.empty ()) {            intx =Sta.top ();            Sta.pop (); cout<<" "<<A[x].s; } cout<<Endl; CNT=0; return ; }    intFlag;  for(inti = x; I < n; i++) {flag=1;  for(intj =0; J < A[i].l.size (); J + +) {            if(A[i].l[j]! = o[y+J]) {flag=0;  Break; }        }        if(flag) {P.push (i);//cout<< "+" <<a[i].s<<endl;Slove (Y+a[i].l.size (),0) ; }    }     if(!flag&&CNT) {        if(P.empty ()) {printf ("No solutions!\n"); return ; } Else {            intx =p.top ();//cout<< "-" <<a[x].s<<endl;P.pop (); Slove (y-a[x].l.size (), x+1); }    }}intMain () {//freopen ("Data.in.txt", "w", stdout);Cin>>N; CIN>>o;  while(!p.empty ()) P.pop ();  for(inti =0; I < n; i++) {cin>>A[i].s;  for(intj =0; J < A[i].s.size (); J + +) {            intm; if(A[i].s[j] >='o') M= (A[i].s[j] +1-'a')/3+1; Elsem = (A[i].s[j]-'a')/3+1; A[I].L+ = (m +'0'); }} slove (0,0); return 0;}
View Code

"Recursive and recursive" phone number

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.