Note that there are some explanatory texts on larger screens.

plurals
  1. POFinding all possible words from inputted phone number
    primarykey
    data
    text
    <p>I have a problem that I need some help in figuring out. I was hoping I could get a few pointers on a better way to approach what i'm doing. My main issue is a few lines below (//This is whats hanging me up) and described at the bottom of page.</p> <p>I need to permutate all possible outcomes of a phone number: (not just dictionary words)</p> <p>I.E. 222-2222</p> <p>Should output a list 3^7 long with all the possible permutations of a,b,c</p> <p>I.E.</p> <pre><code>AAAAAAA AAAAAAB AAAAAAC AAAAABA // THIS IS WHATS HANGING ME UP AAAAABB AAAAABC AAAAACA // HERE TOO AND SO ON </code></pre> <p>MY CODE (purposely shortened for testing) GIVES ME:</p> <pre><code>AAAA AAAB AAAC AABC AACC ABCC ACCC BCCC CCCC </code></pre> <p>I'm a beginning programming student so my knowledge goes as far as using for, while, if, statements and grabbing individual chars from the array.</p> <p>Here's what my code looks like so far: (this is a part of a function. Code missing)</p> <p>char alphaFunc(char n[]){</p> <pre><code>int d1=n[0]-48; int d2=n[1]-48; int d3=n[2]-48; int d4=n[3]-48; int d5=n[4]-48; int d6=n[5]-48; int d7=n[6]-48; int a=0,b=0,c=0,d=0,e=0,f=0,g=0; int i=0; char charArray[10][4]={ {'0','0','0'},{'1','1','1'},{'A','B','C'}, {'D','E','F'},{'G','H','I'},{'J','K','L'},{'M','N','O'}, {'P','R','S'},{'T','U','V'},{'W','X','Y'} }; while(i &lt;=14){ printf("%c%c%c%c\n", charArray[d1][a], charArray[d2][b],charArray[d3][c],charArray[d4][d], charArray[d5][e],charArray[d6][f],charArray[d7][g]); g++; if(g==3){ g=2; f++; } if(f==3){ f=2; e++; } if(e==3){ e=2; d++; } </code></pre> <p>I'm not exactly looking for someone to do this for me I just need a little help in figuring out which sort of statement will work b/c when you have a digit get to CharArray[d-][a] location [3] and reset it to [0] it sends you to a different part of the loop. (hope that makes sense).</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload