عرض مشاركة واحدة
قديم 03-05-2008, 01:42 AM   رقم المشاركة : [2]
ahmedmecha
عضو فعال جداً
الصورة الرمزية ahmedmecha
 

ahmedmecha يستحق التميز

يمكنك إستخدام الكود أدناه



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear,clc

n = input('input number of the counting loops ')

% number(i) is the i-th digit of the input number (should be 0 or 1)

number(1) = input('input the first digit of your number ');
number(2) = input('input the second digit of your number ');
number(3) = input('input the third digit of your number ');
number(4) = input('input the fourth digit of your number ');

for i=1:n
shift = XOR( number(3),number(4) );
% aux is auxiliary vector to save the digits
aux(1) = number(1);
aux(2) = number(2);
aux(3) = number(3);
% replacing the old digits with the new ones
number(1) = shift;
number(2) = aux(1);
number(3) = aux(2);
number(4) = aux(3);
end
'our final number is'

number

لقد جربت البرنامج وهو يعمل

تحياتي




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