English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

how do you solve for an array index if you know the element of the array, but need to 'peal' everything off to find it's index number. Assuming that there is one and only one item in each element such as - cyper code for example ==
index 0 / 1/ 2/ 3/ 4/ 5/ 6/ 7 /8/9 /10/11/12/13/ ........
element c/ d/ e/ f/ g/ h / i / j / k / l/ m/ n/ o/ p/
I have a an arry of encrypted text such as hiddenMessage[1000]and I have the cypher ---- cypher_array[26] and have an empty arrary to fill in such as vola[ 1000] I've made them all myself. But now I need vola[ i ] = 'a' + ix; where ix is the index to the code. I tried just taking the letter in hiddenMessage[ix] and adding 'a' , but this does not yield the correct index number to the cypher code array! Soooo, if I have a letter from an encrypted array, how do I find the corresponding index of that letter in the cyper array ?

2006-12-04 13:52:25 · 3 answers · asked by BIGDAWG 4 in Computers & Internet Programming & Design

3 answers

I think you'll have to search for the letter in the cypher array. If there's no pattern to the cypher, you'll need a loop that iterates through the cypher array until the letter is found. At that point, you'll have the index.

2006-12-04 14:37:26 · answer #1 · answered by arbeit 4 · 0 0

So cypher_array[] is an array of the 26 lowercase letters, where cypher_array[0] is the character associated with the lowercase letter 'a'?

If that's the case, then vola[i] = cypher_array[hiddenMessage[i] - 'a'];

Otherwise, maybe give more detail?

2006-12-04 22:43:09 · answer #2 · answered by rons_brain 2 · 0 0

the truth is there is not enough info to really know what you want really for example:
-if the encrypted massage is number that repersent a place in the the key array the it will look some thing like this:
for (int i=0;i vola[i]=cypher_array[hiddenmassage[i]];
}
-and if its the same thing but is has been shifed by 'a' it will look like this:
for (int i=0;i vola[i]=cypher_array[hiddenmassage[i]+'a'];
/*({[or]})*/
for (int i=0;i vola[i]=cypher_array[hiddenmassage[i]]+'a';
there is to much we can not know from your question sorry that i could not help you that much but this is what i got

2006-12-08 14:49:42 · answer #3 · answered by kfh4497650 2 · 0 0

fedest.com, questions and answers