Armenian Knowledge Base  

Go Back   Armenian Knowledge Base > Technical sections > Languages, Compilers, Interpreters > Algorithms
Register

Reply
 
LinkBack Thread Tools
Old 11.03.2002, 11:06   #1
Дошкольник
 
Join Date: 02 2002
Location: erevan
Posts: 89
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post Паскаль.

Кто знаком с Паскалём, пожалуйста , помогите!

Объявляю переменные
n: integer;
i: array[1..n] of integer;
Компилятор говорит, что n должно уже иметь значение, а оно должно образоваться по ходу дела.
Как представить n , чтоб он этого не говорил?
Спасибо.
Reply With Quote
Old 11.03.2002, 17:32   #2
Дошкольник
 
Join Date: 02 2002
Location: arminko
Posts: 115
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

Ti doljen znachenie n V "const" abyavit', pered var-om. Tagda vsyo budet ok
Reply With Quote
Old 17.03.2002, 08:22   #3
Дошкольник
 
Join Date: 02 2002
Location: erevan
Posts: 89
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

В том-то и дело , что значение n присваивается
потом.
Reply With Quote
Old 18.03.2002, 02:00   #4
Академик
 
greka's Avatar
 
Join Date: 09 2001
Location: inside myself
Posts: 5,369
Downloads: 0
Uploads: 0
Reputation: 18 | 5
Post

A bolee nikakix variantov - ispol'zuj dinamicheski vydeljajemuju pamjat'.
Reply With Quote
Old 19.03.2002, 19:35   #5
Студент
 
Join Date: 01 2002
Location: (premission denied!)
Posts: 347
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

Deystvitel'no, esli razmer vector-a neopredelen, edinstvennyy varian - ispol'zovat' ssylku na vector.

Regrads, Bupyc.
Reply With Quote
Old 21.03.2002, 01:25   #6
aka arpik
 
Andromeda's Avatar
 
Join Date: 02 2002
Location: tre metri sopra il cielo
Age: 32
Posts: 694
Downloads: 0
Uploads: 0
Blog Entries: 1
Reputation: 69 | 4
Post

look, ti doljen napisat' k primeru:
const m=100; {m maximal'noe chislo, kotoroe kstati, mojet i uvelichivat'sya..}
type i:array[1..m] of integer;
a potom uje
--
--
write('n='): readln(n).............
{zdes' zadash' znachenie "n"}...
vot...
Reply With Quote
Old 21.03.2002, 01:34   #7
aka arpik
 
Andromeda's Avatar
 
Join Date: 02 2002
Location: tre metri sopra il cielo
Age: 32
Posts: 694
Downloads: 0
Uploads: 0
Blog Entries: 1
Reputation: 69 | 4
Post

look, ti doljen napisat' k primeru:
const m=100; {m maximal'noe chislo, kotoroe kstati, mojet i uvelichivat'sya..}
type i:array[1..m] of integer;
a potom uje
--
--
write('n='): readln(n).............
{zdes' zadash' znachenie "n"}...
vot...
Reply With Quote
Old 21.03.2002, 05:11   #8
Консервативн
 
VX's Avatar
 
Join Date: 01 2002
Location: Кавказская Албания
Posts: 889
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

..ili mojno vospol'zivatsa dynamiceki rastushim massivom)
Code:
 

   pntr = ^rec;
   rec  = record
      vec  : integer;
      link : pntr;
   end;
i potom dvigatsa...
Reply With Quote
Old 31.05.2002, 00:11   #9
Guru Apprentice
 
Join Date: 02 2002
Location: /dev/null
Age: 41
Posts: 524
Downloads: 0
Uploads: 0
Reputation: 0 | 0
Post

To Andromeda: neelegantno, lishnaya pamyat zabiraetsa i nikogda ne ispolzuetsa

To VX: eto nazivaetsa cepochka (chain). Mozhno kak variant, tolko nado budet esche pisat proceduri izvlechenij i-egogo elementa, proceduri dobavlenia-udaleniya, a to u tebya posle vixoda programmi "nichya" pamyat ostanetsa.

Drugoj variant, ya eto delal let 5 nazad, a mne moj starshij tovarish i uchitel programmirovaniya podskazal. Poskolku delalos 5 let nazad - za sintaksis ne ruchajus, kto znaet pascal pust ispravit, rasskazivaju ideju.

Obyavlyaesh novij type kak pointer na samij bolshoj vozmozhnij massiv (tolko pointer! pamyat ne videlyaetsa).
Zatem v programme poluchiv znachenie dlya 'n' videlyaesh dinamicheski pamyat (v golovu lezet C-shnij ekvivalent malloc, v paskale kak-to po drugomu bilo, MemAlloc kazhetsa??)
"skolkzkoe" mesto - MemAlloc-u nado skazat skolko mesta videlyat. Podschitat prosto: n*sizeof(integer) naprimer. (SizeOf - ne pascal funkciya, pravda?)

Domashnee zadanie - nayti po knizhke pravilnie nazvaniya dlya funkcij.
__________________
\/\/h47'5 1n 4 n4m3? 7h47 wh1(h w3 (4|| 4 r053,
8y 4ny 07h3r n4m3 w0u|d 5m3|| 45 5w337...
Reply With Quote
Old 31.05.2002, 08:59   #10
4294967296
 
Boyov's Avatar
 
Join Date: 03 2002
Location: /proc/1
Age: 33
Posts: 379
Downloads: 4
Uploads: 0
Reputation: 0 | 0
Post

Ya bi v etom sluchae zapixnul bi vse v kakoy nibud' failik i vse.
Reply With Quote
Sponsored Links
Reply

Thread Tools


На правах рекламы:
реклама

All times are GMT. The time now is 01:24.


Powered by vBulletin® Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.