السلام عليكم
برنامج قم ببرمجته بسيط في فكرته
يطلب من المستخدم تحديد العمليه التي يريد القيام بها ..
0 : للقيام بعمليه And
1 : للقيام بعمليه Or
بعد ذلك يطلب منك تحديد طول الـ Bit المراد القيام بمعالجته لنفرض انه 4
ثم نقوم بادخل اول عدد في مصفوفه
1100
ثم نقوم بادخال العدد الاخر في مصفوفه اخرى
0000
سيقوم البرنامج بـ المعالجه و تخزين الناتج في مصفوفه جديده .
Source Code
#include <iostream>
using namespace std;
int main()
{
int path;
cout<<"Welcome Tp Bainary Calculator"<<endl;
cout<<"Enter 0 For : And --- 1 For : Or"<<endl;
cin>>path;
int n;
cout<<"Number Of Bit ? "<<endl;
cin>>n;
bool arr1[100];
bool arr2[100];
bool resarr[100];
int count =0;
int count1 =0;
int count2 =0;
int countA =0;
int countB =0;
int countC =0;
cout<<"Enter Bit ! "<<endl;
while ( count<n )
{
cout<<"x"<<count<<endl;
cin>>arr1[count];
count++;
}
while ( count1 < n)
{
cout<<"y"<<count1<<endl;
cin>>arr2[count1];
count1++;
}
while ( count2 <n)
{
if ( path == 0 )
{
resarr[count2]=(arr1[count2] && arr2[count2] );
count2++;
}
else if (path == 1 )
{
resarr[count2]=(arr1[count2] || arr2[count2] );
count2++;
}
}
while ( countA < n )
{
cout<<arr1[countA];
countA++;
}
cout<<endl;
while (countB<n )
{
cout<<arr2[countB];
countB++;
}
cout<<endl;
cout<<"----"<<endl;
while (countC<n)
{
cout<<resarr[countC];
countC++;
}
cout<<endl;
system("pause");
return 0;
}