Orar semigroup #2

Orar semigroup #2

5/4

Sa se verifice daca 2 stive sunt identice. Stivele se creeaza introducand numere pana la 0, in fiecare.

#include<iostream>
using namespace std;
struct nod{
    int info;
    nod *urm;};

void adaug(int x, nod* &vf)
{nod* p;
p=new nod;
p->info=x;
p->urm=vf;
vf=p;}

void afisare(nod* vf)
{while(vf!=NULL){
    cout<<vf->info<<" ";
    vf=vf->urm;}
}

int main()
{nod *vf1=NULL,*p,*vf2=NULL;
int x,s=0,i=0;

cin>>x;
while(x)
{adaug(x,vf1);
cin>>x;}
cin>>x;
while(x)
{adaug(x,vf2);
cin>>x;}

while(vf1!=NULL){
    if(vf1->info != vf2->info)
    {cout<<"NU"; return 0;}
    else
    vf1=vf1->urm;
    vf2=vf2->urm;}
cout<<"DA";
}

joi, 3 mai 2012 by DlMuresan
Categories: | Leave a comment

Leave a Reply