pk1 Posted October 8, 2007 Report Share Posted October 8, 2007 Zaproponuj algorytm dla następujacego zadania: W skonczonym ciagu dodatnich liczb całkowitych, nie wiekszych niz miliard (to moze być dowolna inna liczba), reprezentujących długosci odcinków, należy znaleźć trzy takie liczby, że z odpowiadających im odcinków mozna zbudować trójkąt. Uwaga: Niech cię nie zdziwi zwiazek tego zadania z liczbami Fibonacciego. Dostałam takie zadanie z olimpiady informatycznej do zrobienia. Studiuje matematyke wiec nie umiem tak dobrze programować w Pascalu. Dla dowolnych 3 odcinków wiem jak napisać program ale co z liczbami Fibonacciego?? Jeżeli ktos mi moze pomóc to bede wdzieczna. Jeżeli komuś zależy na korzyściach (zaplata) z tego to możemy sie dogadać. Mój nr gg 8325929. Prosze o jaknajszybszą pomoc jeśli to mozliwe. Link to comment Share on other sites More sharing options...
KKKas Posted October 8, 2007 Report Share Posted October 8, 2007 Przenieść do działu ogłoszenia. ҉ Link to comment Share on other sites More sharing options...
Force Posted October 8, 2007 Report Share Posted October 8, 2007 Te liczby są posortowane na wejściu? Jedyne co mi się obiło o uszy, to są drzewa fibonnaciego, ale nie wiem czy je trzeba użyć Baza tysięcy lotnisk: http://airportsbase.com Link to comment Share on other sites More sharing options...
pk1 Posted October 8, 2007 Author Report Share Posted October 8, 2007 ten program ma sprawdzać dla dowolnych 3 liczb. wiadomo że jeżeli są to 3 kolejne liczby ciagu fibonacciego bo nie tworzą one trójkąta ale co dla dowolnych?? jak napisać taki algorytm z uwzględnieniem liczb fibonacciego?? Link to comment Share on other sites More sharing options...
Force Posted October 8, 2007 Report Share Posted October 8, 2007 Oj pytam się, czy dostajesz liczby posortowane na wejściu czy nie Baza tysięcy lotnisk: http://airportsbase.com Link to comment Share on other sites More sharing options...
pk1 Posted October 8, 2007 Author Report Share Posted October 8, 2007 nie muszą być posortowane. ale to jes najmniejszy problem. Link to comment Share on other sites More sharing options...
lewymati Posted October 10, 2007 Report Share Posted October 10, 2007 sortujesz sobie liczby w kolejności rosnącej Sprawdzasz trzy ostatnie liczby - jeśli tworzą trójkąt to wypisujesz je i kończysz program, jeśli nie to usuwasz ostatni element i wykonujesz całość jeszcze raz Nie widzę tutaj związku z liczbami fibbonaciego Piszę proste programy i stronki internetowe na zlecenie, zaliczenie... Delphi, Pascal, C++, (X)HTML, CSS, trochę PHP, Javascript i MySQL Kontakt: gg:1477872 e-mail: lewymati@wp.pl Link to comment Share on other sites More sharing options...
pauletsonka Posted October 24, 2007 Report Share Posted October 24, 2007 a jak bedzie wygladal program, ktory sprawdza czy z dowolnych 3 odcinkow mozna skonstruowac trojkat?? Link to comment Share on other sites More sharing options...
5corpio Posted October 24, 2007 Report Share Posted October 24, 2007 Suma 2 boków > od trzeciego ? czy jakoś tak to było ;p Ot taka mini-strona moja po godzinach http://www.wnetrzekuchni.pl Link to comment Share on other sites More sharing options...
pauletsonka Posted October 24, 2007 Report Share Posted October 24, 2007 ale mi odpowiedz.... Link to comment Share on other sites More sharing options...
Force Posted October 25, 2007 Report Share Posted October 25, 2007 Cóż, matematyczna, lepsza niż "trywialne". Musisz sprawdzić czy suma dwóch (dowolnyhc) boków jest większa od trzeciego, jeśli tak to trójką się złoży Baza tysięcy lotnisk: http://airportsbase.com Link to comment Share on other sites More sharing options...
pauletsonka Posted October 25, 2007 Report Share Posted October 25, 2007 cos takiego??? to fragment programu z jednym warunkiem, a maja byc 3 warunki ? uses crt; var a,b,c,d,e,f: integer; begin writeln ('podaj dlugosc pierwszego odcinka'); readln (a); writeln ('podaj dlugosc drugiego odcinka'); readln (B); writeln ('podaj dlugosc trzeciego odcinka'); readln ©; d:= a+b; e:= a+c; f:= b+c; if d>c then begin writeln ('z tych odcinkow da sie skonstruowac trojkat'); readln; end; Link to comment Share on other sites More sharing options...
KKKas Posted October 25, 2007 Report Share Posted October 25, 2007 Cio???????? ҉ Link to comment Share on other sites More sharing options...
Force Posted October 25, 2007 Report Share Posted October 25, 2007 Bardzo ładne kolorowanie składni. Pomyśl, że te zmienne "e" i "f" nie są tam bez powodu i coś z nimi porównać trzeba Baza tysięcy lotnisk: http://airportsbase.com Link to comment Share on other sites More sharing options...
pauletsonka Posted October 25, 2007 Report Share Posted October 25, 2007 no napisane jest przeciez, ze to fragment... co nie ? ale cos w tym stylu? Link to comment Share on other sites More sharing options...
pauletsonka Posted October 25, 2007 Report Share Posted October 25, 2007 e>b f>a?? tak ma byc ?? tak? Link to comment Share on other sites More sharing options...
oksal Posted October 25, 2007 Report Share Posted October 25, 2007 poprawności odcinków budujących trójkąt : wersja a) p:=(a+b+c)/2; if (p-a)*(p-b)*(p-c)>0 then buduj; 6ui' if (a+b>c)and(b+c>a)and(c+a>b) then buduj; edit:poprawione pozdrawiam oksal Link to comment Share on other sites More sharing options...
pauletsonka Posted October 30, 2007 Report Share Posted October 30, 2007 Ale jak wezme boki 2, 2, 1, to przy wersji B nie zbuduje niby trojkata. a przeciez zbuduje i jest to trojkat rownoramienny!! Link to comment Share on other sites More sharing options...
5corpio Posted October 30, 2007 Report Share Posted October 30, 2007 Oksal chyba masz błąd: (a-b>c)and(b-c>a)and(c-a>b) Nie powinny być sumy przypadkiem a nie różnice ? Ot taka mini-strona moja po godzinach http://www.wnetrzekuchni.pl Link to comment Share on other sites More sharing options...
oksal Posted October 30, 2007 Report Share Posted October 30, 2007 Masz rację, sumy mają być. Cholera ze tez tego nie zauważyłem ... pozdrawiam oksal Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.