cout << i_LengthOfService;
gotoxy (58,y);
cout << i_RateOfPay;
gotoxy (1,y+1);
}
DataBaseType& DataBaseType::NewData (char *surname, char *name, char *patronymic,
char *post,int lengthofservice, int rateofpay)
{
CS_Surname = surname;
CS_Name = name;
CS_Patronymic = patronymic;
CS_Post = post;
i_LengthOfService = lengthofservice;
i_RateOfPay = rateofpay;
return *this;
}
CRecord& CRecord::operator= (const CRecord &r)
{
record = r.record;
next = r.next;
pred = r.pred;
return *this;
}
void CRecord::print ()
{
record.print ();
}
inline CContr::CContr ():head_record(0),current_record(0),last_record(0)
{
head_record = new CRecord;
head_record->IsBgn = 1;
last_record = new CRecord;
last_record->IsEnd = 1;
head_record->next = last_record;
last_record->pred = head_record;
}
CContr::~CContr ()
{
while (head_record)
{
current_record = head_record;
head_record = head_record->next;
delete current_record;
}
}
void CContr::AddRecord (const CRecord &given_record)
{
CRecord* new_record = new CRecord(given_record);
if (head_record->next == last_record)
{
head_record->next = new_record;
new_record->pred = head_record;
new_record->next = last_record;
last_record->pred = new_record;
}
else
{
MoveEnd();
current_record->next = new_record;
new_record->pred = current_record;
new_record->next = last_record;
last_record->pred = new_record;
}
MoveEnd();
}
void CContr::xchg(CRecord *f_record,CRecord *s_record)
{
f_record->xchg_point(s_record);
}
void CRecord::xchg_data (CRecord &another_record)//перестановка звеньев списка по полям
{
record.xchg_data (another_record.record);
}
void CContr::sort ()
{
int flag(1);
if (!head_record)
return;
if (IsEmpty())
return;
while (flag)
{
MoveBgn ();
flag = 0;
while (!current_record->next->IsEnd)
{
if (current_record->record.Surname() > current_record->next->record.Surname())
{
xchg (current_record,current_record->next);
if (!flag)
flag = 1;
}
if (current_record->IsEnd || current_record->next->IsEnd)
break;
MoveNext();
}//while(current_record)
}//while(flag)
MoveBgn();
}
void CContr::MoveNext ()
{
if (current_record->next)
{
current_record = current_record->next;
}
}
void CContr::MovePrev ()
{
if(current_record)
{
current_record = current_record->pred;
}
}
void CContr::MoveEnd()
{
if (head_record->next != last_record)
{
current_record = last_record->pred;
}
else
{
current_record = last_record;
}
}
void CContr::MoveBgn ()
{
if (head_record->next != last_record)
{
current_record = head_record->next;
}
else
{
current_record = head_record;
}
}
void CContr::DelCur()
{
if (current_record && !current_record->IsBgn && !current_record->IsEnd)
{
current_record->pred->next = current_record->next;
current_record->next->pred = current_record->pred;
delete current_record;
MoveBgn();
}
}
void CRecord::xchg_point (CRecord *r)//перестановка звеньев списка по указателям
{
const CRecord this_record (*this);
const CRecord given_record (*r);
if (next == r)
{
next = r->next;
next->pred = this;
pred->next = r;
pred = r;
r->pred = this_record.pred;
r->next = this;
}
else
{
pred->next = r;
pred = r->pred;
next = r->next;
r->next = this_record.next;
next->pred = this;
r->pred->next = this;
this_record.next->pred = r;
r->pred = this_record.pred;
}
}
int CContr::IsEnd()
{
if (current_record->IsEnd)
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.