You should use [co
de][/co
de] tags. Paste your code in between them so it gets formatted properly. Nothing is more annoying (other than homework questions where the OP hasn't even tried the question) than 300 lines of code without code tags >:O
Anyway as you've at least tried and are asking specific questions (we get alot of posts where the OP hasn't even asked anything; just copied the question out of their book or whatever), it's ok.
As I understand it, s/he wants you to store the 4 digit number with cin. Then s/he wants you to split it into 4 separate digits. This would be very much easier with a loop and an array but you may not have studied loops and arrays yet. If you have, that simplifies things; if not, then that complicates things. If you've done loops and arrays you may well get more points but I don't want to tell you to do something that gets you marked down...
Anyway once you have your four digits you need to do this:
Replace each digit by performing the calculation (the sum of that digit plus 7) modulo 10. |
digit1 = ((digit1 + 7) % 10);
which assigns the value of x + 7 % 10. For example, take x to be 3. x + 3 == 10. 10 % 10 == 0. So digit1 would be 0 if it had previously been 3. Does that make sense?
Then you need to
Swap the first digit with the third, and swap the second digit with the fourth. |
1 2
|
digit1 = digit3;
digit2 = digit4;
|
Then you can do something like:
std::cout << "Encrypted digits: " << digit1 << " " << /* etc. */
You might consider how to write an application that will decrypt these values.] |
I think he may be hinting at your next assignment. Think about how you got the results you got, and then how you'll get the original numbers back.
7 + 3 == 10, 10 - 3 == 7. Think about that.
Anyway hope that clears things up.