rectangle (x,y,x+170,y+15);
setfillstyle (1,i);
bar (x+175,y,x+190,y+15);
}
if (c==1)
{ setcolor(0);
bar (170,0,340,480); }
return i;}
int style ()
{ int c=1,x=350,y=10,i=0;
setcolor (15);
outtextxy (x+5,15,"0-Цвет фона"); outtextxy (x+5,45,"1-Сплошной");
outtextxy (x+5,75,"2-Линия"); outtextxy (x+5,105,"3-Диагональ");
outtextxy (x+5,135,"4-Диагональ"); outtextxy (x+5,165,"5-Диагональ");
outtextxy (x+5,195,"6-Диагональ"); outtextxy (x+5,225,"7-Решетка");
outtextxy (x+5,255,"8-Решетка"); outtextxy (x+5,285,"9-Горошек");
outtextxy (x+5,315,"10-Горошек"); outtextxy (x+5,345,"11-Горошек");
outtextxy (x+5,375,"12-Прозрачный");
rectangle (x,y,x+170,y+15);
while (c!=13&&c!=27)
{ c=getch();
setcolor (0);
rectangle (x,y,x+170,y+15);
setfillstyle (1,0);
bar (x+175,y,x+190,y+15);
if (c==80) {y+=30;i++;}
if (c==72) {y-=30;i--;}
if (i==-1) {i=12;x=350;y=370;}
if (i==13) {i=0;x=350;y=10;}
setcolor (15);
rectangle (x,y,x+170,y+15);
setfillstyle (i,15);
bar (x+175,y,x+190,y+15); }
if (c==1)
{ setcolor(0);
bar (170,0,340,480); }
return i;}
typedef class elem
{ sect Sect;
int key;
friend spis_Sect;
public:
void output(void);
void input (void);};
void elem::output()
{ gotoxy(1,1);
printf ("Ключ: %d",key);
getch();
Sect.change();}
void elem::input()
{ outtextxy (340,240,"Введите ключ");
scanf ("\n%d",&key);
Sect.interDan();
}
typedef struct elem_Spis
{ elem_Spis *prev,*next;
elem e;
elem_Spis(){next=NULL; prev=NULL;};};
typedef class spis_Sect
{ elem_Spis *begin;
public:
void add(elem); // Dobavlenie elementa v spisok
void del(int); // Udaleni iz spiska po KEY
void option (int,int); // Poisk v spiske po KEY i izmenenie sv-v
void print (); // Vivod vseh elementov v pramom poradke
void print_back(); // Viviod vseh el-ov v obratnom poradke
spis_Sect(){begin->next=begin; begin->prev=begin; begin->e.key=0;};
};
void spis_Sect::add(elem e)
{ elem_Spis *q;
q=new elem_Spis;
q->prev=begin->prev;
begin->prev->next=q;
begin->prev=q;
q->next=begin;
q->e=e;}
void spis_Sect::del(int key)
{ elem_Spis *q;
q=begin->next;
while (q!=begin&&q->e.key!=key)
q=q->next;
if (q->e.key==key)
{ q->prev->next=q->next;
q->next->prev=q->prev;
delete q; }
}
void spis_Sect::option(int key,int sv)
{ elem e;
if (begin!=NULL)
{ elem_Spis *q;
q=begin->next;
while (q->e.key!=key&&q!=begin)
q=q->next;
if (q->e.key==key)
{ if (sv==1) q->e.Sect.setfillColor(color());
else q->e.Sect.setfillStyle(style()); }
}}
void spis_Sect::print ()
{ elem_Spis *q;
if (begin->next!=begin)
{ q=begin->next;
while (q!=begin)
{ q->e.output();
q=q->next; }
}}
void spis_Sect::print_back ()
{ if (begin->prev!=begin)
{ elem_Spis *q;
q=begin->prev;
while (q!=begin)
{ q->e.output();
q=q->prev; } }}
spis_Sect options (spis_Sect Spis)
{ int x=170,y=75,c=-1,i=1;
outtextxy (x+5,y+5,"Выбор цвета закраски");
outtextxy (x+5,y+35,"Выбор стиля закраски");
outtextxy (x+5,y+65,"Назад");
setcolor (15);
rectangle (x,y,x+170,y+15);
while (i!=4)
{ while (c!=13)
{ c=getch();
setcolor (0);
rectangle (x,y,x+170,y+15);
if (c==80) {y+=30;i++;}
if (c==72) {y-=30;i--;}
if (i==0) {i=3;x=170;y=135;}
if (i==4) {i=1;x=170;y=75;}
setcolor (15);
rectangle (x,y,x+170,y+15); }
switch (i)
{ case 1: { gotoxy(50,1); printf("Ключ "); int k; scanf("%d",&k); Spis.option(k,i);
c=-1; break; }
case 2: { gotoxy(50,1); printf("Ключ "); int k; scanf("%d",&k); Spis.option(k,i);
c=-1; break; }
case 3: {c=13; i=4; break;} }
setfillstyle (1,0);
bar (350,0,640,480);
}
return Spis;}
spis_Sect dann(spis_Sect spis)
{ int c=1,x=170,y=75,i=1;
setbkcolor(0);
setcolor (15);
outtextxy (x+5,80,"Добавить"); outtextxy (x+5,110,"Удалить"); outtextxy (x+5,140,"Назад");
rectangle (x,y,x+150,y+15);
while (i!=3)
{ while (c!=13)
{ setcolor (0);
rectangle (x,y,x+150,y+15);
if (c==80) {y+=30;i++;}
if (c==72) {y-=30;i--;}
if (i==0) {i=3;x=170;y=135;}
if (i==4) {i=1;x=170;y=75;}
setcolor (15);
rectangle (x,y,x+150,y+15);
c=getch(); }
switch (i)
{ case 1: {elem e; e.input(); spis.add(e); c=-1; break;}
case 2: {printf("Ключ "); int k; scanf("%d",&k); spis.del(k); c=-1; break;}
case 3: {c=13; i=3; break;} }
setfillstyle (1,0);
bar (330,0,640,480); }
return spis;}
spis_Sect print_menu (spis_Sect spis)
{ int c=1,x=170,y=75,i=1;
setbkcolor(0);
setcolor (15);
outtextxy (x+5,80,"в прямом порядке");
outtextxy (x+5,110,"в обратном порядке");
outtextxy (x+5,140,"Назад");
rectangle (x,y,x+180,y+15);
while (i!=3)
{ while (c!=13)
{ setcolor (0);
rectangle (x,y,x+180,y+15);
if (c==80) {y+=30;i++;}
if (c==72) {y-=30;i--;}
if (i==0) {i=3;x=170;y=135;}
if (i==4) {i=1;x=170;y=75;}
setcolor (15);
rectangle (x,y,x+180,y+15);
c=getch(); }
switch (i)
{ case 1: {spis.print(); c=13; i=3; break;}
case 2: {spis.print_back(); c=13; i=3; break;}
case 3: {c=13; i=3; break;} }
setfillstyle (1,0);
bar (330,0,640,480); }
return spis;}
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.