X
XADD
C++:
#include <iostream>
using namespace std;
class List
{
class Node
{
public:
int d;
int Year;
char Author;
char Name;
Node *next;
Node *prev;
Node (int dat=0, int year=0, char Author=0, char Name=0)
{
d=dat;
Year=year;
next=0;
prev=0;
}
};
Node *pbeg,*pend;
public:
List() {pbeg=0; pend=0;}
~List()
{
if (pbeg!=0)
{
Node *pv=pbeg;
while (pv)
{
pv=pv->next;
delete pbeg;
pbeg=pv;
}
}
}
void Add (int d, int year, char Author, char Name)
{
Node *pv = new Node(d,year,Author,Name);
if (pbeg==0) pbeg=pend=pv;
else
{
pv->prev=pend;
pend->next=pv;
pend=pv;
}
}
void Print ()
{
Node *pv=pbeg;
cout << endl << "List: ";
while (pv)
{
cout << pv->d << ' ';
cout << pv->Year << ' ';
cout << pv->Author << '';
cout << pv->Name << '';
pv=pv->next;
}
cout << endl;
}
};
int main()
{
List l;
char a,b;
cin >> a;
cin >> b;
l.Add(1,1990,a,b);
l.Print();
return 0;
}