0 / 0 / 0
Регистрация: 05.12.2019
Сообщений: 7
1

Не работает кейс-меню

19.01.2020, 21:24. Показов 596. Ответов 0
Метки нет (Все метки)

Author24 — интернет-сервис помощи студентам
Всем привет! Возникла такая ошибка: во фри паскале кейс-меню не реагирует вообще ни на какие действия. До этого программа была без процедуры Graph и модулей Graph и wincrt, все работало. После этого перестало.
Вот код:


Pascal
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
program int; 
uses crt, Math, Graph, wincrt; 
const menuitems: array [1..6] of string =( 
'Info', 
'Enter borders', 
'Enter step', 
'Square and Inaccuracy', 
'Graph', 
'Exit'); 
 
function Funct(x:real):real; 
begin 
Funct:= x*x*x + 2*x*x + x + 7; 
end; 
 
function Pervo(x:real):real; 
begin 
Pervo:= 1/4*x*x*x*x + 2/3*x*x*x + 1/2*x*x +7*x; 
end; 
 
var a, b, s, h, h1, s1, n, x, f, pog: real; 
var UN, i: integer; 
var C1, C2: boolean; 
var h2: longint; 
var Key: char; 
var Gd, Gm: smallint; 
 
procedure vvodgr; 
begin 
writeln ('Write left border, a= '); 
readln (a); 
writeln ('Write right border, b= '); 
readln (b); 
if a <-2.631 then begin 
writeln ('a>-2.630'); 
writeln ('Write left border, a= '); 
readln (a); 
writeln ('Write right border, b= '); 
readln (b); 
end; 
if b<a then begin 
writeln ('Borders are not correct'); 
writeln ('Write left border, a= '); readln (a); 
writeln ('Write right border, b= '); readln (b); 
end; 
writeln ('(Press enter to exit the menu)'); 
C1:= true; 
readln (); 
end; 
 
procedure step1; 
begin 
writeln ('Write a step'); 
readln (n); 
h1:= (b-a); 
if (n<0) or (n>h1) then begin 
writeln ('Incorrect step. Please try again'); 
readln; 
end; 
if (n>0) and (n<=h1) then 
writeln ('(Press enter to exit the menu)'); 
readln; 
C2:=true; 
end; 
 
procedure menu (UN: integer); 
var Item: integer; 
begin 
for Item:= 1 to length (menuitems) do begin 
if Item = UN then 
TextBackground (LightRed) 
else TextBackground (Black); 
Writeln (Item, '.', menuitems[Item]); 
TextBackground (Black); 
end; 
 
end; 
 
procedure sqin; 
begin 
s:=0; 
x:=a; 
h:=(b-a)/n; 
h2:= Round (h); 
f:=0; 
for i:=0 to h2-1 do 
begin 
x:= a+h2*n; 
s1:=Funct (x); 
s:=s+s1; 
end; 
s:=s*n; 
Gotoxy (27, 10); 
writeln ('Square is ', s: 0:6); 
begin 
pog:=Pervo(b)-Pervo(a); 
end; 
Gotoxy (25, 12); 
Writeln ('Absolute inaccuracy= ', Abs (pog-s): 5:6); 
GotoXy (25, 13); 
Writeln ('Relative inaccuracy= ', ((Abs (pog-s))/s)*100: 3:6, '%'); 
Gotoxy (25,15); 
writeln ('(Press enter to exit the menu)'); 
end; 
 
procedure graph; 
var x0, y0, x3, y3, xLeft, yLeft, xRight, yRight, n2, colx, coly, jk, y4: integer; 
a1, b1, fmin, fmax, x1, y1, mx, my, dx, dy, num: real; 
l: byte; 
s2: string; 
chaf: char; 
begin 
colx:= 3; 
coly:= 3; 
clrscr; 
Gd:= Detect; 
InitGraph (Gd, Gm, ''); 
a1:= -6; b1:= 6; dx:= 0.5; 
fmin:= -250; fmax:= 250; dy:= 50; 
repeat 
jk:=0; 
x0:= 0; 
xLeft:= 25; 
yLeft:= 25; 
xRight:= GetMaxX - 50; 
yRight:= GetMaxY - 50; 
mx:= (xRight - xLeft)/(b1-a1); 
my:= (yRight - yLeft)/(fmax-fmin); 
x0:= trunc (abs(a1)*mx) + xLeft; 
y0:= yRight - trunc (abs(fmin)*my); 
Setcolor (15); 
line (xLeft, y0, xRight, y0); 
line (x0, yLeft, x0, yRight); 
Setcolor (4); 
SetTextStyle(1, 0, 1); 
OutTextXY (xRight+20, y0 - 15, 'X'); 
OutTextXY (x0 - 15, yLeft - 10, 'Y'); 
Setcolor (14); 
OutTextXY (x0 - 10, y0 + 10, '0'); 
x1:=a1; 
while x1 <= b1 do 
begin 
y1:= Funct (x1); 
x3:= x0 + Round (x1 * mx); 
y3:= y0 - Round (y1 * my); 
y4:=y3; 
if (x1>=a) and (x1<=b) and (x3<>x0) then 
begin 
Setcolor (2); 
if y4<yLeft then y4:=yLeft; 
line (x3, y4, x3, y0 - 2); 
end; 
if (y3 >= yLeft) and (y3 <= yRight) then PutPixel (x3, y3, 12); 
x1:= x1 + 0.0001; 
end; 
Setcolor (14); 
n2:= Round ((b1-a1)/dx) + 1; 
for l:= 1 to n2 do 
begin 
num:= a + (l-1) * dx; 
x3:= xLeft + trunc (mx* (num-a)); 
Line (x3, y0 - 3, x3, y0 + 3); 
str(Num:0:1, s2); 
if abs(num) > 1E-15 then 
OutTextXY (x3 - TextWidth(s2) div 2, y0+ 10, s2) 
end; 
n2:= Round ((fmax - fmin)/dy) + 1; 
for l:= 1 to n2 do 
begin 
num:= fMin + (l-1) * dy; 
y3:= yRight - trunc (my * (num - fmin)); 
Line (x0 - 3, y3, x0 + 3, y3); 
str (num:0:0, s2); 
if abs (num) > 1E-15 then 
OutTextXY (x0 + 7, y3 - TextHeight (s2) div 2, s2) 
end; 
Setcolor (2); 
OutTextXY (400, 10, 'F(x)= x^3+2x^2+x+7'); 
OutTextXY (0, 20, 'Zoom in X and Y - "Up arrow"'); 
OutTextXY (0, 32, 'Reduce X and Y - "Down arrow"'); 
OutTextXY (0, 44, 'Zoom in X - "Insert"'); 
OutTextXY (0,56,
 
'Reduce X - "PGUP"'); 
OutTextXY (0, 68, 'Zoom in Y - "Delete"'); 
OutTextXY (0, 80, 'Reduce Y - "PGDN"'); 
OutTextXY (0,92, 'Exit - "Esc"'); 
chaf:= wincrt.readkey; 
if chaf=#0 then chaf:= wincrt.readkey; 
case chaf of 
#82: begin 
if (colx<6) then 
begin 
a1:= a1 * 2; b1:= b1 * 2; dx:= dx*2; 
colx:= colx+1; 
cleardevice 
end 
else 
begin 
OutTextXY (0, 106, 'Error - X max limit'); 
delay (600); 
cleardevice; 
end; 
end; 
#73: begin 
if (colx>1) then 
begin 
a1:= a1/2; b1:= b1/2; dx:= dx/2; 
colx:=colx-1; 
cleardevice; 
end 
else 
begin 
OutTextXY (0, 106, 'Error - X min limit'); 
delay (600); 
cleardevice; 
end; 
end; 
#83: begin 
if (coly<6) then 
begin 
fmin:=fmin*2; fmax:=fmax*2; dy:= dy*2; 
coly:=coly+1; 
cleardevice; 
end 
else 
begin 
OutTextXY (0, 106, 'Error - Y max limit'); 
delay (600); 
cleardevice; 
end; 
end; 
#81: begin 
if (coly>1) then 
begin 
fmin:=fmin/2; fmax:=fmax/2; dy:=dy/2; 
coly:=coly-1; 
cleardevice 
end 
else 
begin 
OutTextXY (0, 106, 'Error - Y min limit'); 
delay (600); 
cleardevice; 
end; 
end; 
#75: begin 
if (colx<6) then 
begin 
a1:= a1*2; b1:= b1*2; dx:= dx*2; 
colx:=colx+1; 
cleardevice 
end 
else 
begin 
OutTextXY (0, 106, 'Error - X max limit'); 
delay (600); 
cleardevice; 
end; 
if (coly<6) then 
begin 
fmin:=fmin*2; fmax:=fmax*2; dy:= dy*2; 
coly:= coly+1; 
end 
else 
begin 
OutTextXY (0, 118, 'Error - Y max limit'); 
delay (600); 
cleardevice; 
end; 
end; 
#77: begin 
if (colx>1) then 
begin 
a1:= a1/2; b1:= b1/2; dx:= dx/2; 
colx:= colx-1; 
end 
else 
begin 
OutTextXY (0, 106, 'Error - X min limit'); 
delay (600); 
end; 
if (coly>1) then 
begin 
fmin:=fmin/2; fmax:=fmax/2; dy:= dy/2; 
coly:=coly-1; 
end 
else 
begin 
OutTextXY (0, 118, 'Error - Y min limit'); 
delay (600); 
cleardevice; 
end; 
cleardevice; 
end; 
end; 
until chaf=#27; 
closeGraph; 
end; 
 
 
begin 
C1:= false; 
C2:= false; 
UN:= 1; 
while true do begin 
clrscr (); 
menu (UN); 
while true do begin 
Key:= ReadKey (); 
if Key = #13 then break; 
if Key <> char (0) then continue; 
Key:= ReadKey(); 
case Key of 
#72: UN:= UN - 1; 
#80: UN:= UN + 1; 
end; 
if UN > length (menuitems) then UN:=1 
else if UN <1 then UN:= length (menuitems); 
clrscr(); 
menu (UN); 
end; 
clrscr (); 
menu (0); 
Writeln (); 
case UN of 
1: begin 
Gotoxy (32, 7); 
writeln ('f(x)= x^3+2x^2+x+7'); 
Gotoxy (31,8); 
writeln ('Left rectangle method'); 
Gotoxy (29, 10); 
writeln ('(Press enter to continue)'); 
readln (); 
end; 
2: vvodgr; 
3: step1; 
4: begin 
if ((C1=false) or (C2=false)) then begin 
writeln ('Enter all data'); 
end 
else begin 
sqin; 
end; 
readln (); 
end; 
5: graph; 
6: exit; 
end;
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
19.01.2020, 21:24
Ответы с готовыми решениями:

Правильно ли написана программа?Осталось добавить кейс меню в эту программу
1. Реализовать программу вычисления площадь фигуры, ограниченной кривой 1*х^3+(-2)*x^2+(-4)*x+(10)...

Компьютер включается не с первого раза,то есть сам кейс работает а монитор не показывает ничего
Всем добрый вечер.На данный момент возникла следующая проблема:Компьютер включается не с первого...

Не работает меню. Должно скрывать меню и раскрывать.
Беда в том, что меню не работает в JS. Должно скрывать меню и раскрывать. &lt;!DOCTYPE html&gt;...

кейс в цикле
Еще раз здравствуйте, уважаемые форумчане. Написал запрос, общая структура которого такова: ...

0
19.01.2020, 21:24
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
19.01.2020, 21:24
Помогаю со студенческими работами здесь

Элитный Кейс
Доброго времени суток, уважаемые форумчане. У меня такая проблема, я пытаюсь воссоздать в...

Задача на кейс
Подскажите как выполнить данную задачу Локатор ориентирован на одну из сторон света («С» — север,...

Оператор кейс
Составить программу которая бы с помощью оператора кейс реализовала бы все возможные операции над...

Меню не работает. Кнопки меню не активны
ссылка на программу, она сюда не помещается


Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:
1
Ответ Создать тему
Опции темы

КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2024, CyberForum.ru