عرض مشاركة واحدة
منتديات طلاب وطالبات جامعة الملك عبد العزيز منتديات طلاب وطالبات جامعة الملك عبد العزيز
قديم 21-05-2010, 06:22 PM   #4

Mr.Ahmad

عضو هيئة تدريس

الصورة الرمزية Mr.Ahmad

 
تاريخ التسجيل: Jul 2008
كلية: كلية الحاسبات وتقنية المعلومات
التخصص: IT
نوع الدراسة: عضو هيئة تدريس
المستوى: متخرج
البلد: جــــدة
الجنس: ذكر
المشاركات: 2,477
افتراضي رد: سوال c++ماادري من وين مخترعينو

المشاركة الأصلية كتبت بواسطة galaxy55 مشاهدة المشاركة
السلام عليكم ورحمه الله وبركاته
كل يومين يخرعولنا سوال جديد مدري من وين
حتى الفكره تعي تطلع معاينقرتين لعرض الصورة في صفحة مستقلةنقرتين لعرض الصورة في صفحة مستقلةنقرتين لعرض الصورة في صفحة مستقلة
-----------------
4- (Cryptography) A company wants to transmit data over the telephone, but is
concerned that its phones could be tapped. All of the data are transmitted as four-digi
integers. The company has asked you to write a program that encrypts the data so th
it can be transmitted more securely. Your program should read a four-digit integer an
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.
-----------
دا السوال
اذا تكرمتو
وعليكم السلام ورحمة الله وبركاته .

تفضل الحل :
كود PHP:
#include <iostream>
#include <conio.h>
//using namespace std;

int digitSeparator (int numberint digit)
{
 
int level 1,cur 0;
 while (
level <= numberlevel *= 10;
 
cur level;
 for (
int i 1<= digit i++) cur /= 10;
 return (
number/cur) % 10;
}


int passDigit (int x)
{
 
7;
 if (
>= 10digitSeparator(x,2);
 return 
x;
}


void main ()
{
 
int x,result 0;
 
cout << "Please Enter 4 Digit -> ";
 
cin >> x;
 
result += passDigit(digitSeparator(x,3)) * 1000;
 
result += passDigit(digitSeparator(x,4)) * 100;
 
result += passDigit(digitSeparator(x,1)) * 10;
 
result += passDigit(digitSeparator(x,2)) * 1;
 
cout << "Rsult = " << result << endl;
 
getch();

بالتوفيق .

 

توقيع Mr.Ahmad  

 

سبحان الله وبحمد ,,, سبحان الله العظيم
الحمد لله كما ينبغي لجلال وجهه وعظيم سلطانه .
اللهم صل على محمد وعلى آل محمد كما صليت على إبراهيم وعلى آل إبراهيم إنك حميد مجيد . اللهم بارك على محمد وعلى آل محمد كما باركت على إبراهيم وعلى آل إبراهيم إنك حميد مجيد.

 

Mr.Ahmad غير متواجد حالياً   رد مع اقتباس