Sunday, July 12, 2009

C - plus plus array processing question?

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 ?

C - plus plus array processing question?
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.
Reply: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?
Reply: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%26lt;size;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%26lt;size;i++){


vola[i]=cypher_array[hiddenmassage[i]+'a...


/*({[or]})*/


for (int i=0;i%26lt;size;i++){


vola[i]=cypher_array[hiddenmassage[i]]+'...


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


No comments:

Post a Comment