Please Help! Can anyone explain how to do this?

C Each number on a phone corresponds to three alphabetic characters. Write a code that prints all possible words formed (regardless of whether or not they make sense) from any 7-digit telephone number.

10 件のコメント

the cyclist
the cyclist 2015 年 4 月 29 日
Start by reading this, which gives a lot of help on how to solve the problem you have. Then come back here.
Tony
Tony 2015 年 4 月 29 日
編集済み: the cyclist 2015 年 4 月 29 日
n=input('Input a 7 digit number')
AB={ 'a b c d e f g h i j k l m n o p q r s t u v w x y z'};
for i=1:n;
f= (i)*char(AB)/3;
end
disp(f)
this is what i have so far, I am not sure how to make 3 letter words appear for a 7 any digit phone number.
Star Strider
Star Strider 2015 年 4 月 29 日
On my phone, ‘7’ has ‘PQRS’ while all the others (from 1-9) have 3 letters each. I would create a cell array of the letter groups, each referenced by a single digit from 1-9, create the 7-digit phone numbers, and go from there.
It would be helpful if ‘word’ was defined a bit more precisely by the maximum number of letters, especially if they don’t all have to make sense. Otherwise you could get everything from ‘a’ to ‘supercalifragilisticexpialidocious’
Guillaume
Guillaume 2015 年 4 月 29 日
編集済み: Guillaume 2015 年 4 月 29 日
@star, it does say from a 7-digit telephone number
Ilham Hardy
Ilham Hardy 2015 年 4 月 29 日

I am amazed that the word actually have a meaning, or should i say i am supercalifragilisticexpialidocious

Tony
Tony 2015 年 4 月 29 日
i am totally clueless
Star Strider
Star Strider 2015 年 4 月 29 日
@Tony — That makes two of us!
@Guillaume — Therein lies the problem.
If I’m reading the problem correctly, a 7-digit telephone number would have a total of 21 (or 22) letters, not necessarily unique since numbers can repeat.
So to me there are two possibilities:
  1. do we map from 7 letters that can encode a 7-digit telephone number, or
  2. from a 7-digit telephone number that can produce 21 or 22 letters?
It’s not clear to me from the question.
the cyclist
the cyclist 2015 年 4 月 29 日
To me, it is fairly clear. You enter a 7-digit phone number, which would lead to (3^7) possible 7-letter "words" if there were exactly 3 characters per key.
James Tursa
James Tursa 2015 年 4 月 29 日
@Cyclist: Seems fairly clear to me also. Groupings on my phone would be something like this:
LETTERS = {'','','ABC','DEF','GHI','JKL','MNO','PQRS','TUV','WXYZ'}
with a digit "k" corresponding to LETTERS{k+1}
Star Strider
Star Strider 2015 年 4 月 29 日
Fair enough. It was the ‘7-letter words’ I wasn’t picking up on.

回答 (0 件)

この質問は閉じられています。

タグ

質問済み:

2015 年 4 月 29 日

閉鎖済み:

2021 年 8 月 20 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by