Uploaded by moon iq

Q15 DATA

advertisement
#include <iostream>
using namespace std;
#define n 4
void push(int stack[n], int& top, int x) // ‫اإلضافة دالة بناء‬
{
if (top >= n - 1) cout << "stack over flow \n";
else
{
top++;
stack[top] = x;
}
}
void print(int stack[n], int& top) {
for (int i = 0; i <= top; i++)
cout << stack[i];
}
void main()
{
int arr[n];
int ss1[n], ss2[n], top1 = -1, top2=-1;
cout << "inter array element\n";
for (int i = 0; i < n; i++)
cin >> arr[i];
for (int i = 0; i < n; i++)
if (arr[i] % 2 == 0)
push(ss1, top1, arr[i]);
else
push(ss2, top2, arr[i]);
cout << "the fisrt stack even\n";
print(ss1, top1);
cout << "\n";
cout << "the secound stack odd\n";
print(ss2, top2);
}
Download