Răspuns :
#include <iostream>
using namespace std;
struct Nod {
int value;
Nod* next;
};
Nod* cap = NULL;
void inserareInceput(Nod*& cap, int valoare)
{
Nod* p = new Nod;
// Construim noul nod
p->value = valoare;
p->next = cap;
cap = p;
}
void afisareLista(Nod* cap) {
while (cap != NULL)
{
cout << cap->value << " ";
cap = cap->next;
}
}
void afisareElementePareLista(Nod* cap) {
while (cap != NULL)
{
if (cap->value % 2 == 0)
{
cout << cap->value << " ";
}
cap = cap->next;
}
}
int main()
{
int n;
cin >> n;
while(n != 15){
cin >> n;
inserareInceput(cap, n);
}
afisareLista(cap);
cout << endl;
afisareElementePareLista(cap);
}
e mai naspa dar na daca faceam ca rayzen zicea ca e copy :)))
#include<iostream>
#include<stack>
using namespace std;
int main(){
stack<int> s,v;
int x;
cin>>x;
while(x!=15){
s.push(x);
v.push(x);
cin>>x;
}
while (!s.empty()) {
cout<<' '<<s.top();
s.pop();
}
cout<<endl;
while (!v.empty()) {
if(v.top()%2==0)
cout<<' '<<v.top();
v.pop();
}
return 0;
}