← Back to topics
Topic

Boxes

d
dario-dsa
Whay my code did not work?
var a,b,c,d,e,f,g,h:integer;
begin
readln(a,b,c);
readln(d,e,f);
g:=a+b+c;
h:=d+e+f;
if g=h then writeln('NE')
else
writeln('DA');
readln;
end.

http://www.z-trening.com/new/www/html/submit.php?subm_stat=1&submit=7100053385
f
fushar
because your algorithm is wrong...
N
Nikola94
try this example:
4 7 10
3 5 19

well, in this case output should be "NE" but your code will output "DA". here's a hint.sort the lengths of the first box(a,b,c) and then the second box(d,e,f). then compare each length of the first box with the corresponding length of the second box( a with d, b with e, c with f). YOU MUST SORT THEM FIRST AND THEN COMPARE THEM. i hope you understood what i tried to tell you... :)
m
matteo123
it should be NE
4 7 10
3 5 19
because :
4>3,7>5 and 10<19
d
dario-dsa
In pascal don't have sort.
u pascalu nema sort.
p
picsel
You should learn some simple sort algorithm then, like Bubble Sort.
A
Al3kSaNdaR
Try to google sorts like Bubble, Insertion, Selection.
L
Lovro-lpa
http://www.youtube.com/watch?v=myKlT30nl5Y
Alogirtam koji sortira brijeve (među najpopularnijim algoritmima za sortiranje)
m
matteo123
http://www.youtube.com/watch?v=vxENKlcs2Tw
Quick Sort vs. Bubble Sort