I have been stumped on this for a long time and I was wondering if anyone can help me out. How could I write a program that would calculate the shift value of an encrypted Caesar’s Cypher file in C++? My assignment is to take each lower case letter and calculate how many times each is used, then find the most frequent character. I know I can do that with a map of char and int. But then I would have to go back to that letter to change it to the letter ‘e’. With maps there’s no way to search back through values. I think the only way is a vector of vectors but I wouldn’t know how to find the letter again with those either. Does anyone know a better way or how could I use vectors to accomplish this?
Share
You can go like this.
charkey andintvalue. with all alphabets and values 0Loop over whole buffer till end incrementing value in map by 1 for each character. Also maintain
maxvariable storing key ha of character having maximum value.At end of loop
maxvariable will point to e.maxwill give you shift value for this cipher. If it comes negative then you can add 26. (As this calculation in in mod 26)