مرحبا شباب هذا سؤال وانا حليته بس ابغى تعديل عليه:
==-=-=
-----
A company wants to transmit data over the telephone, but they are concerned that their phones may be tapped. All of their data is transmitted as four-digit
Integers . Thy have asked you to write a program that encrypts their data so
That it may be transmitted more securely. Your program should read a four-digit Integer and encrypt it as follows: Replace each digit by ( the sum of that digit plus 7 ) modulus 10. Then, swap the first digit with the third, swap the second digit with the fourth, and print the encrypted integer. Write a separate program
That inputs an encrypted four-digit integer, and decrypts it to form the original number
=-=-=
وهذا الحل
#incllude
#include
void encrypt( int n ) {
cout << setw(4) << setfill('0') <<
((((n % 10) + 7) % 10) * 100 )
+ ((((n / 10 % 10) + 7) % 10) * 1000 )
+ ((((n / 100 % 10) + 7) % 10) * 1 )
+ ((((n / 1000 % 10) + 7) % 10) * 10 );
}
int main()
{
int n;
cin >> n;
if (n <= 9999) {
encrypt( n );
} else {
cout << "ERROR: Non 4-digit number entered." << endl;
return 1;
}
return 0;
}ـــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ
هذا الحل بس ابغى مساعده في وتعديل ان البرنامج يرجع ويفك الشفره من جديد يعني باسورد ثم تشفير نم فك التشفير وارجاع للباسورد الاصلي ........ واريده في برنامج واحد يعني دمج برنامجين ببرنامج واحد تشفير وفك التشفير ........
ارجو افادتي اخواني