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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
| #include <stdio.h>
#include <conio.h>
#include <string.h>
#include <math.h>
#include <dos.h>
#include <graphics.h>
struct diciplina
{
char name_predmet[20];
int lec, sem, lab;
};
struct prepodavatel
{
diciplina predmet;
char FIO[25];
};
struct auditoria
{
int nomer_audit[2];
int id[3]; //èäåГ*ГІГЁГґГЁГЄГ*òîð: 0 - ëåêöèÿ, 1- ñåìèГ*Г*Г°, 3- Г«Г*áîðГ*òîðГ*Г*Гї
};
struct group
{
int n_gr;
int n_podgruppy; //max - 2 podgruppy: 1 and 2
};
void input ()
{
diciplina dic;
prepodavatel pr;
auditoria audit;
group gr;
char filename[100];
int vsego_audit=0;
printf ("\nViberite deystvie\n");
printf ("\n1). Sozdat` file\n");
printf ("\n2). Otkrit` file\n");
fflush (stdin);
char d=getche ();
FILE *F;
if (d=='1')
{
printf ("\nVvedite imya dlya novogo faila\n");
gets (filename);
F=fopen (filename, "wb+");
}
if (d=='2')
{
printf ("\nVvedite imya faila\n");
gets (filename);
F=fopen (filename, "rb+");
if (F)
printf ("\nFile sushestvuet!\n");
else
{ printf ("File ne sushestvuet!\n");
printf ("\nViberite deistvye:\n");
printf ("\n1). Sozdat file\n");
printf ("\n2). Vyhod!\n");
d=getche ();
if (d=='1')
{
printf ("\nVvedite imya dlya novogo faila\n");
gets (filename);
F=fopen (filename, "wb+");
}
if (d=='2')
return;
}
}
{
do
{ fflush (stdin);
printf ("\nVyberute deistvie: \n");
printf ("\n1). Dobavit dannye\n");
printf ("\n2). Posmotret` dannye\n");
printf ("\n3). Sozdat file zanovo \n");
printf ("\n4). Vyhod!");
d=getche ();
if (d=='4') break;
if (d=='3')
{
printf ("\nVvedite imy dly novogo faila\n");
gets (filename);
F=fopen (filename, "wb+");
}
if (d=='1')
{
F=fopen (filename, "ab+");
do
{ fflush (stdin);
printf ("Vvedite FIO prepodavatelya, provod. zanyatiye: \n");
gets (pr.FIO);
printf ("\n Vvedite naim.discipliny: \n");
gets (dic.name_predmet);
printf ("\n Vvedite kol-vo lekciy po etoy discipline: \n");
scanf ("%d", &dic.lec);
printf ("Vvedite kol-vo seminar. zanyatiy po etoy discipline: \n");
scanf ("%d",&dic.sem);
printf ("Vvedite kol-vo lab.rabot po etoy discipline: \n");
scanf ("%d", &dic.lab);
printf ("Vvedite nomera vozmozhnyh auditoriy dlya dannogo zanyatiya: \n");
for (int i=0; i<2; i++)
scanf ("%d", &audit.nomer_audit[i]);
fwrite (&pr, sizeof(pr), 1, F);
fwrite (&audit, sizeof(audit), 1, F);
fwrite (&dic,sizeof(dic), 1, F);
printf ("\nProdolzat' vvod: [D/H]\n");
fflush (stdin);
d=getche ();
}
while (d=='D' || d=='d');
fclose (F);
}
}
while (d!=1 || d!=2 || d!=3);
}
}
void inf ()
{ initwindow (800, 600);
setcolor (4);
outtextxy (0, 0, "Nazvanie programmy: Raspisanie zanyatiy. Chtoby posmotret optimalnoe raspisanie, nazhmite 1.");
}
int main ()
{
int key;
int menu1;
char d = '\0';
do
{
initwindow (800, 600);
settextstyle (0, 0, 32); //0 0 4
setcolor (3);
outtextxy (250, 100, "Raspisanie");
setcolor (10);
setlinestyle (0, 0, 5);
circle (175, 185, 30);
outtextxy (160, 170, "1");
outtextxy (220, 170, "Vvod dannyh");
setcolor (2);
circle (175, 250, 30);
outtextxy (159, 235, "2");
outtextxy (220, 235, "Spravka");
circle (175, 315, 30);
outtextxy (159, 300, "3");
outtextxy (220, 300, "Exit!");
getch ();
if (d=='3') break;
fflush(stdin);
if (_kbhit())
{
key=_getch();
switch (key)
{
case 49:
input (); break;
case 50:
inf (); break;
}
}
}
while (menu1!=3);
closegraph ();
} |