Форум программистов, компьютерный форум, киберфорум
Pascal (Паскаль)
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
0 / 0 / 0
Регистрация: 04.10.2011
Сообщений: 17

Паскаль(ошибка в коде)

02.11.2011, 15:07. Показов 922. Ответов 0
Метки нет (Все метки)

Студворк — интернет-сервис помощи студентам
У меня такая ошибка уже замучился её искать помогите пож
stack overflow error (сложите ошибку переполнения)




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
Type _TaskList = (_update, _remove);
type _strategy = (_search, _lookingforCenter, _lookingforBounds, _notDefined,
_lookingforCool);
const maxcol=45;
      maxrow=41;
      bound_value=400;
       diag = 2300;
 
const maxlev : longint = 3;
 
Type Table = array [0..maxrow+1, 0..maxcol+1] of integer;
 
 
var c : integer;
  t : table;
  qre                          : integer;
  strategy                     : _strategy;
  zone                         : table;
  gluk, was                          : table;
 
current, move, curmax, maxmove : longint;
flower : integer;
 maxx,curr : array [0..20] of longint;
 GameState : Longint;
 
procedure clear(y, x, flower, setcol  : byte);
begin
   if (t[y][x]=0) then exit;
   if was[y][x]=1 then exit;
   was[y][x] := 1;
   if (t[y][x]=flower) then begin
      t[y][x] := setcol;
      clear(y, x+1,flower, setcol);
      clear(y, x-1,flower, setcol);
      clear(y-1, x,flower, setcol);
      clear(y+1, x,flower, setcol);
      exit;
   end;
end;
 
procedure Fill(y, x, col : byte);
begin
   if (t[y][x]=0) then exit;
   if t[y][x]=col then exit;
   if was[y][x]=1 then exit;
   was[y][x] := 1;
      fill(y, x+1, col );
      fill(y, x-1, col);
      fill(y-1, x, col);
      fill(y+1, x, col);
      exit;
 
end;
 
 
procedure search(lev : integer);
var
 color : integer;
qqr,  i : integer;
savc, curc : integer;
_task : _TaskList;
frc, toc : integer;
ccr : longint;
function get(x, y, lev : longint) : longint;
begin
 get := x+y;
{ if (x=maxCOl) then get := 10000*y*(maxlev-lev);
 if (y=maxRow) then Get := 10000*x*(maxlev-lev);}
end;
procedure qsearch(y, x : integer);
begin
 if was[y, x] = 1 then exit;
 
 if (t[y][x]=toc) and (_task=_update) then begin
          was[y][x] := 1;
          inc(current, get(x, y,lev)); zone[y][x] := lev; inc(qre);
          qsearch(y, x+1);
          qsearch(y, x-1);
          qsearch(y-1, x);
          qsearch(y+1, x);
 end;
end;
procedure update(y, x : byte);
begin
   if (t[y][x]=0) then exit;
   if was[y][x]=1 then exit;
   was[y][x] := 1;
   if (t[y][x]=frc) then begin
      if (_task = _update) or (zone[y][x]<>lev) then begin
       t[y][x] := toc;
       if zone[y][x] = -1 then zone[y][x] :=-2;
      end else begin
        dec(current, get(x, y,lev)); zone[y][x] := -1; dec(qre);
      end;
      update(y, x+1);
      update(y, x-1);
      update(y-1, x);
      update(y+1, x);
      exit;
   end;
   if _task = _update then
       if t[y][x]=toc then
         begin
          inc(current, get(x, y,lev)); zone[y][x] := lev; inc(qre);
          qsearch(y, x+1);
          qsearch(y, x-1);
          qsearch(y-1, x);
          qsearch(y+1, x);
         end;
end;
 
procedure makeit(t : _TaskList; frmcol, tocol : integer);
begin
 _task := t;
 frc := frmcol;
 toc := tocol;
 fillchar(was, sizeof(was), 0);
 update(1, 1);
end;
begin
 if lev = maxlev then begin
  for i := maxlev-1 downto 0 do begin
   if maxx[i] > curr[i] then break;
   if maxx[i] < curr[i] then break;
  end;
  if Curr[i] > Maxx[i] then
   begin Maxx := Curr; MaxMove := Move; end;
  exit;
 end;
 savc := t[1][1];
 for i := 1 to 6 do
  begin
    if (i<>savc) and ((i<>flower) or (lev<>0)) then begin
      if lev = 0 then
       move := i;
      ccr := current;
      qqr := qre;
      makeit(_update,  savc, i);
      curr[lev] := current;
 
      search(lev+1);
      makeit(_remove,  i, savc);
    end;
  end;
end;
{--------------------------------------------------------------------}
procedure mark(var a : table; _type : integer; var b : table; col : integer);
var i, j : integer;
begin
 for i := 1 to MaxRow do
  for j := 1 to MaxCol do begin
    if a[i][j] = _type then b[i][j] := col;
  end;
end;
{--------------------------------------------------------------------}
procedure AnalyzeIntPoints;
var tt : Table;
 c : integer;
 i, j : integer;
begin
    fillchar(was, sizeof(was), 0);
    fill(1, 1, 7);
    mark(was, 0, t, 7);
    tt := t;
    fillchar(Was, sizeof(Was), 0);
    clear(1, 1, t[1,1], 9);
    fillchar(Was, sizeof(Was), 0);
    fill (MaxRow, MaxCol, 9);
    mark(t, 9, was, 1);
    mark(was, 0, t, 9);
    c := 0;
    for i := 1 to MaxRow do
     for j := 1 to MaxCol do begin
      if not (t[i][j] in [7, 9]) then
       c := 1;
      if t[i][j] = 9 then inc(GameState);
      if (t[i][j] = 9) and (i*MaxCol+j*MaxRow>diag) then Strategy:=_Lookingforbounds;
     end;
    if (t[Maxrow][1] in [7, 9]) and (t[1][maxCol] in [7, 9]) then
     strategy := _search;
    if (gamestate>900) {or ({(gamestate>300) and (gamestate<500))} then Strategy := _Search;
    gluk := t;
    t := tt;
    if c<>0 then mark(was, 0, t, 9);
    fillchar(Was, sizeof(Was), 0);
end;
 
var i, j : integer;
    ch : char;
 
procedure SearchWays(var when, color : table; x, y : integer; flower : integer; badColor : integer);
 var
 find : boolean;
 flag : boolean;
 min : integer;
 CHK : INTEGER;
procedure update(a, b, c, d : integer);
begin
    if find then exit;
    if t[a][b]=9 then exit;
    if gluk[a][b]=badColor then exit; { Testing t[a][b] is neutral }
    if when[c][d] = - 1 then exit;
    if (when[c][d]=0) and (t[a][b]=flower) then exit;
    if (when [a][b] = -1) or (when[c][d] < when [a][b]) then
     begin
      CHK := WHEN[A][B];
       when[a][b] := when[c][d];
       if t[a][b]<>t[c][d] then inc(when[a][b]);
       if when[c][d]=0 then color[a][b] := t[a][b] else
         color[a][b] := color[c][d];
       IF CHK<>WHEN[A][B] THEN   flag :=true;
     end;
end;
begin
  find := false;
  fillchar(when, sizeof(when), 255);
  when[y][x] := 0;
  repeat
   flag := false;
   for i := 1 to maxRow do
    for j := 1 to maxCol do begin
       update(i,j, i-1, j);
       update(i,j, i+1, j);
       update(i,j, i, j-1);
       update(i,j, i, j+1);
    end;
  until not flag;
end;
 
procedure FindCenter;
var when, color : table;
i, j : integer;
min : integer;
begin
 searchways(when, color, 1, 1, flower, t[maxrow, maxcol]);
 min := maxint;
 maxmove := 0;
  for i := 1 to maxRow do
   for j := 1 to maxCol do begin
    if (i*MaxCol+j*MaxRow > Diag)  and (when[i][j] <min) and (when[i][j]<>-1) then
     begin min := when[i][j]; maxmove := color[i][j] end;
   end;
 if maxmove = 0 then strategy := _lookingforBounds;
end;
 
procedure FindBounds;
var
  whW, whH, colW, ColH : table;
i, j : integer;
ctr : integer;
min, max : integer;
 
procedure FindCool;
var i, j, k : integer;
 col : integer;
begin
 
 max := 0;
 for k := 1 to 6 do begin
 col := 0;
 for i :=1 to MaxRow do
   for j := 1 to MaxCol do begin
     if (whh[i][j] - whw[i][j] > 0) and (whh[i][j] < 30000) and (colw[i][j]=k) then begin
      inc(col);
     end;
   end;
  if col > max then begin MaxMove := k; max := col ; end;
 end;
end;
 
begin
 
  searchways(whW, ColW, 1, 1, flower, t[maxrow, maxcol]);
  fillchar(was, sizeof(was), 0);
  searchways(whh, ColH, MaxCol, MaxRow, t[1, 1], 9);
 
    mark(whH, -1, whh, MaxInt);
    mark(whW, -1, whW, MaxInt);
    max := 0;
 
  maxMove := 0;
  min := maxint;
  ctr := 5;
 
    for i := MaxRow downto 1 do begin
     for j := 1 to i do
      if whw[i][MaxCol]=0 then ctr := i-j;
     if (WhH[i][MaxCol] - WhW [i][maxcol]>=1) and  (whW[i][maxcol] < min) and (ctr>=10) then begin
      min := whW[i][MaxCol]; maxMove := colW[i][MaxCol]; break;
     end;
  end;
 
  ctr := 5;
  for i := MaxCol downto 1 do begin
    for j := 1 to i do
     if whw[maxRow][i]=0 then ctr := i-j;
    if (whH[MaxRow][i]-WhW[MaxRow][i]>=1) and (whW[MaxRow][i] <min) and (ctr >=10) then
      begin   min := WhW[MaxRow][i]; maxMove := colW[MaxRow][i]; break; end;
 end;
 
 if maxMove = 0 then
   FindCool;
 
 if MaxMove = 0 then Strategy := _Search;
end;
 
begin
    assign(input, 'filya.in'); reset(input);
 
    for i := 1 to maxrow do begin
     for j := 1 to maxCol do begin
      read(ch); t[i][j] := ord(ch)-48;
     end;
     readln;
    end;
 
    fillchar(zone, sizeof(zone), 255);
    flower := t[maxRow, MaxCol];
    fillchar(Was, sizeof(Was), 0);
    clear(maxRow, MaxCol, t[maxRow,Maxcol], 7);
    strategy := _lookingforcenter;
    AnalyzeIntPoints;
 
    fillchar(Was, sizeof(Was), 0);
 
    if strategy=_lookingForCenter then  FindCenter;
    if strategy= _lookingforBounds then findbounds;
 
 
    if maxmove = 0 then
    for i := 1 to 6 do begin
     if (i<>flower) and (i<>t[1][1]) then begin MaxMove :=i; break; end;
    end;
 
    if strategy = _Search then
    begin
     if gameState > 800 then MaxLev := 1;
     fillchar(zone, sizeof(zone), 255);
     search(0);
    end;
    assign(output, 'filya.out'); Rewrite(output);
 
    writeln(maxMove);
end.
входной файл filya.in седержит 41 строчку по 45 цифр в каждой без пробелов.
а вот сылка самой задачи http://www.fvn2009.narod.ru/Ol... ules43.htm
(там задача номер 2 Простофиля)

filya.txtfilya.txt

только там надо преименовать txt на in (так не закачиавалось)
0
Programming
Эксперт
39485 / 9562 / 3019
Регистрация: 12.04.2006
Сообщений: 41,671
Блог
02.11.2011, 15:07
Ответы с готовыми решениями:

Исправление ошибок в коде Паскаль
Задание. Составить блок-схему алгоритма и программу на языке ПАСКАЛЬ вычисления значения функции Y=F(x) для аргумента x, изменяющегося от...

Ошибка в коде ассемблера + паскаль
program Test_1; uses Crt; var x,y,z,f:integer; begin clrscr; write('x: '); readln(x); write('y: '); readln(y);

Ошибка в коде взаимодействия клиента и сервера на основе протокола TCP/IP (ошибка в коде)
Задание: Осуществить взаимодействие клиента и сервера на основе протокола TCP/IP. Реализовать параллельное соединение с использованием...

0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
inter-admin
Эксперт
29715 / 6470 / 2152
Регистрация: 06.03.2009
Сообщений: 28,500
Блог
02.11.2011, 15:07
Помогаю со студенческими работами здесь

Удалить комментарии в коде Паскаль
Нужно создать программу на Си, которая будет удалять комментарии в паскале

Что неправильно в коде программы паскаль? , просит точку с запятой перед else в операторе if
program z8; var s:string; k,p,i,d:byte; begin writeln('vvedite chifri razdelaya tochkami, na konce *'); readln(s); k:=0; ...

Как в коде Паскаль отобразить математический символ, который называется Сведение по Карпу?
Мне нужно найти произведение положительных элементов массива. Символ этот означает: левое сводимо по Карпу к правому, левое &quot;не...

Ошибка с графикой в приложении Windows form (ошибка не в коде!)
Всем доброго времени суток! Написал программу в windows form. Несколько раз скомпилировал и все хорошо. Сейчас попробовал снова запустить...

Ошибки в коде Qt - ошибка: undefined reference to `qMain(int, char**)'; ошибка: error: ld returned 1 exit status
Здравствуйте, есть проект в нем 2 ошибки, не очень понимаю как их можно решить. Помогите, буду признателен! Вот main.cpp #include...


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

Или воспользуйтесь поиском по форуму:
1
Ответ Создать тему
Новые блоги и статьи
Отправка уведомления на почту при изменении наименования справочника
Maks 24.03.2026
Программная отправка письма электронной почты на примере изменения наименования типового справочника "Склады" в конфигурации БП3. Перед реализацией необходимо выполнить настройку системной учетной. . .
модель ЗдравоСохранения 5. Меньше увольнений- больше дохода!
anaschu 24.03.2026
Теперь система здравосохранения уменьшает количество увольнений. 9TO2GP2bpX4 a42b81fb172ffc12ca589c7898261ccb/ https:/ / rutube. ru/ video/ a42b81fb172ffc12ca589c7898261ccb/ Слева синяя линия -. . .
Midnight Chicago Blues
kumehtar 24.03.2026
Такой Midnight Chicago Blues, знаешь?. . Когда вечерние улицы становятся ночными, а ты не можешь уснуть. Ты идёшь в любимый старый бар, и бармен наливает тебе виски. Ты смотришь на пролетающие. . .
SDL3 для Desktop (MinGW): Вывод текста со шрифтом TTF с помощью библиотеки SDL3_ttf на Си и C++
8Observer8 24.03.2026
Содержание блога Финальные проекты на Си и на C++: finish-text-sdl3-c. zip finish-text-sdl3-cpp. zip
Жизнь в неопределённости
kumehtar 23.03.2026
Жизнь — это постоянное существование в неопределённости. Например, даже если у тебя есть список дел, невозможно дойти до точки, где всё окончательно завершено и больше ничего не осталось. В принципе,. . .
Модель здравоСохранения: работники работают быстрее после её введения.
anaschu 23.03.2026
geJalZw1fLo Корпорация до введения программа здравоохранения имела много невыполненных работниками заданий, после введения программы количество заданий выросло. Но на выплатах по больничным это. . .
Контроль уникальности заводского номера
Maks 23.03.2026
Алгоритм контроля уникальности заводского (или серийного) номера на примере нетипового документа выдачи шин для спецтехники с табличной частью, разработанного в конфигурации КА2. Данные берутся из. . .
Хочу заставить корпорации вкладываться в здоровье сотрудников: делаю мат модель здравосохранения
anaschu 22.03.2026
e7EYtONaj8Y Z4Tv2zpXVVo https:/ / github. com/ shumilovas/ med2. git
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2026, CyberForum.ru