[ Outline ] · Standard · Linear+

> Help! Hitno Do Cetvrtka!, Zadatak pascal

Magdalina_kg
post Feb 24 2009, 10:28 PM
Post #1





Group: Članovi
Joined: 20-October 07
Member No.: 717
Status: Van MGa
Ime i prezime: Magdalina Čivović
Škola/Razred: Obdareni u matematičkoj gimnaziji-Prva kragujevačka gimnazija



zadatak mi treba u pascalu- formiranje binarnog stabla ako su listovi zadati u nizu,pa treba doci do korena.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
 
Reply to this topicStart new topicStart Poll
Replies
pyost
post Feb 24 2009, 11:20 PM
Post #2


Deus Ex Makina
Group Icon

Group: Administratori
Joined: 25-January 06
From: Beograd
Member No.: 2
Status: Bivši učenik MGa
Škola/Razred: RAF



Mozda nije najjednostavnije, ali sta sad...

CODE
program stablo;
var
n, i, t: integer;
niz: array[1..100] of integer;

begin
write('Unesite N: ');
readln(n);

writeln('Unesite elemente poslednjeg reda:');

for i:=1 to n do
 readln(niz[i]);
 
while (n > 1) do
begin
 t := 1;
 i := 1;
 
 while (i <= n) do
 begin
  if (i = n)
   then
    begin
     niz[t] := niz[n];
     n := n + 1;
    end
   else
    begin
     if (niz[i] > niz[i+1])
      then niz[t] := niz[i]
      else niz[t] := niz[i+1];    
    end;
 
  i := i + 2;
  t := t + 1;
 end;

 n := n div 2;
end;

writeln('Vrednost korena je ', niz[1]);
readln();
end.


A mozda nije ni tacno laugh.gif


--------------------
Baby, it's a violent world.

Registrovani korisnik Linuxa broj 460770 [Ubuntu 7.10]
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Magdalina_kg
post Feb 25 2009, 09:21 AM
Post #3





Group: Članovi
Joined: 20-October 07
Member No.: 717
Status: Van MGa
Ime i prezime: Magdalina Čivović
Škola/Razred: Obdareni u matematičkoj gimnaziji-Prva kragujevačka gimnazija



QUOTE(pyost @ Feb 25 2009, 12:20 AM)
Mozda nije najjednostavnije, ali sta sad...

CODE
program stablo;
var
n, i, t: integer;
niz: array[1..100] of integer;

begin
write('Unesite N: ');
readln(n);

writeln('Unesite elemente poslednjeg reda:');

for i:=1 to n do
 readln(niz[i]);
 
while (n > 1) do
begin
 t := 1;
 i := 1;
 
 while (i <= n) do
 begin
  if (i = n)
   then
    begin
     niz[t] := niz[n];
     n := n + 1;
    end
   else
    begin
     if (niz[i] > niz[i+1])
      then niz[t] := niz[i]
      else niz[t] := niz[i+1];    
    end;
 
  i := i + 2;
  t := t + 1;
 end;

 n := n div 2;
end;

writeln('Vrednost korena je ', niz[1]);
readln();
end.


A mozda nije ni tacno laugh.gif
*







hvala ti,ali potrebno je formiranje binarnog stabla i sve to,lako bismo mi da mora samo max... stefan je pogresno objasnio
















User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Posts in this topic
Magdalina_kg   Help! Hitno Do Cetvrtka!   Feb 24 2009, 10:28 PM
Magdalina_kg   RE: Help! Hitno Do Cetvrtka!   Feb 24 2009, 10:36 PM
stefikg   RE: Help! Hitno Do Cetvrtka!   Feb 24 2009, 10:36 PM
pyost   RE: Help! Hitno Do Cetvrtka!   Feb 24 2009, 10:48 PM
stefikg   RE: Help! Hitno Do Cetvrtka!   Feb 24 2009, 11:08 PM
pyost   RE: Help! Hitno Do Cetvrtka!   Feb 24 2009, 11:09 PM
stefikg   RE: Help! Hitno Do Cetvrtka!   Feb 24 2009, 11:13 PM
pyost   RE: Help! Hitno Do Cetvrtka!   Feb 24 2009, 11:20 PM
Magdalina_kg   RE: Help! Hitno Do Cetvrtka!   Feb 25 2009, 09:21 AM
VIP <3   RE: Help! Hitno Do Cetvrtka!   Feb 24 2009, 11:22 PM
pyost   RE: Help! Hitno Do Cetvrtka!   Feb 25 2009, 09:25 AM
calamity   RE: Help! Hitno Do Cetvrtka!   Feb 25 2009, 09:30 AM
pyost   RE: Help! Hitno Do Cetvrtka!   Feb 25 2009, 09:41 AM
stefikg   RE: Help! Hitno Do Cetvrtka!   Feb 25 2009, 12:23 PM
SBS   RE: Help! Hitno Do Cetvrtka!   Feb 26 2009, 10:18 PM
calamity   RE: Help! Hitno Do Cetvrtka!   Feb 27 2009, 12:21 AM


Reply to this topicTopic OptionsStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members: