Before attempting to decrypt that you need to know the shift value, and whether it was shifted right or left. I suppose you could solve it by iterating through all 26 possible shift values ('A' - 'Z' = 1-26) assuming case is ignored.If not then there would be at least 127 possible values, which includes every key that can be typed on the American keyboard (except special keys). First try a shift of 1 Right, look at the results to see if it makes sense. If not, then use 2R and repeat the process.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
Well, all you have to do is subtract 3 from the character
int main()
{
char c = 'A';
if( isalpha(c) )
{
c -= 3;
if( c < 'A')
{
c = 'Z' - ('A' - c)+1;
}
}
cout << c << '\n';
}
Now put that in a loop and do it for each character in which isalpha() is true. You will also have to modify that program to recognize lower-case characters.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
for each character? that way the code will be too long, and I for some reason don't see a void or any other user defined function... IT HAS TO BE IN HERE! it's all my homework is about.
So you were expecting us to write your program for you? Not gonna happen. You're taking the class, you know what a void function is, you program what you can. We can help you correct it, but you still have to write it.
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
Also: using CAPS and BOLDTAGS with EXCLAMTIONMARKS!! is probably not going to motivate the people here to help you.
Nick Evan
Not a Llama
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
I didn't mean for you to just blindly copy the code snippet I posted 52 times for each character, but use it as an example of how to do it in a loop. I showed you how to do it for one character, now you should be able to expand on that and do it for all the characters is the string. You can put the code in another function if you want to, but that's not really needed.
I think the whole point is to teach you how to solve problems. You won't learn if we do all the work for you.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
First, if you don't know how to construct code to solve a problem, how do you know that blindly modifying would make the code work the way it should be? Second, if someone post a working code, it is a working code! So why do you need to modify it anyway? Is this the way you do your homework? By getting someone else solution and change variable names? If you don't show us you understand but don't know how to solve the problem (apply an algorithm), we would be gladly to help you. If you just come here and ask us to deliver the code for you, I doubt you would get it that way.
Taywin
Posting Virtuoso
1,727 posts since Apr 2010
Reputation Points: 229
Solved Threads: 239
Looks like we have another one, guys...
OK, here's the deal. This is not a forum where you request a program and we jump to it and write code for you. If you want that, many of us can be hired to code it for you. At the going rate.
And using the BS that if we write it for you give you a better chance to learn is not going to help. That's such a pathetic idea. It's also called cheating.
Write some code and we'll help you fix it. Free. Otherwise, many of us have access to PayPal.
WaltP
Posting Sage w/ dash of thyme
10,505 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
The code you posted a couple hours ago --
main() opens a file then immediately closes it. What is the purpose of that? If you are not going to do anything with the file then why bother opening it?
line 51 appears to be outside a function. Move it up before line 50.
>>But wrong way! It won't show anything
Because you never told it to show something. originalLetters() function is never called. Do you own a TV set? If yes, then you know that you have to turn it on before it will show you something. Same in computer program. originalLetters() exists but won't do anything if its never called.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343