include conio include stdlib include stdio include string int pos int

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include <conio.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int pos=6;
int change[7][4]=
{
{0,1,2,0},{1,1,3,0},{0,6,4,2},{1,3,5,6},{2,5,4,4},{3,5,5,4},{0,3,4,2}
};
char name[7][5]={"lab1","lab2","lab3","lab4","lab5","lab6","HELP"};
int coord[7][2]=
{
{30,9},{37,9},{27,11},{41,11},{30,13},{37,13},{34,11}
};
void bg_window();
void print_menu();
void select_menu();
void help();
void main(int argc, char *argv[])
{
int key;
if(strcmp(argv[1], "/help")==0 || strcmp(argv[1], "/h")==0)
{
bg_window();
select_menu();
}
else
{
bg_window();
switch(key)
{
case 72:pos=change[pos][0];break;
case 77:pos=change[pos][1];break;
case 80:pos=change[pos][2];break;
case 75:pos=change[pos][3];break;
case 13:select_menu();break;
case 27:exit();
}
}
void bg_window()
{
int i;
window(2,2,79,24);
textbackground(BLUE);
textcolor(GREEN);
clrscr();
puts(" ╔══════════════════════════════════════════════════════════════════════════╗ ");
for(i=0;i<=20;i++)
puts(" ║ ║ ");
puts(" ╚══════════════════════════════════════════════════════════════════════════╝ ");
}
void print_menu()
{
int i;
window(5,3,76,23);
textbackground(BLUE);
clrscr();
for(i=0;i<7;i++)
{
window(8,coord[i]+3,15,coord[i]+3);
textcolor(i==pos?LIGHTRED:YELLOW);
textbackground(i==pos?GREEN:RED);
clrscr();
gotoxy(3,1);
cprintf("%s", menu[i]);
}
}
void select_menu()
{
int key;
window(5,3,76,23);
textbackground(BLUE);
textcolor(YELLOW);
clrscr();
switch(pos)
{
case 0:
help();
break;
case 1: case 2: case 3: case 4: case 5: case 6:
cprintf("Лабораторная работа номер %d", pos);
break;
}
for(;;)
{
if(getch()==27)
break;
}
}
void help()
{
FILE *f;
char *c;
int y=2;
if((f=fopen("HELP", "rt"))==NULL)
{
cprintf("\nОшибка открытия файла!\n");
}
else
{
while(!feof(f))
{
c=fgetc(f);
if(c=='\n')
{
gotoxy(1,y++);
}
else
{
cprintf("%c", c);
}
}
fclose(f);
}
}