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.
I need to permutate all possible outcomes of a phone number: (not just dictionary words)
I.E. 222-2222
Should output a list 3^7 long with all the possible permutations of a,b,c
I.E.
AAAAAAA
AAAAAAB
AAAAAAC
AAAAABA // THIS IS WHATS HANGING ME UP
AAAAABB
AAAAABC
AAAAACA // HERE TOO AND SO ON
MY CODE (purposely shortened for testing) GIVES ME:
AAAA
AAAB
AAAC
AABC
AACC
ABCC
ACCC
BCCC
CCCC
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.
Here's what my code looks like so far: (this is a part of a function. Code missing)
char alphaFunc(char n[]){
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 <=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++;
}
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).