@Nutzu
1) Referitor la algoritmul de sortare... m-am prins ca nu ai pus randul ala cu true, stai linistit, ideea e ca functioneaza oarecum... diferit codul de cum ai explicat de unde inteleg ca... nu ai inteles nimic din el si ar trebui sa te mai uiti putin peste
2) emi ti-a oferit for free o implementare a metodei lui morpheus si tu nu ti-ai dat seama... adica hai sa parcurgem rand-cu-rand ce ti-a explicat el...
morpheus wrote:C'mon.
Declari un vector v, avand 100 de elemente: v[1..100]
Initializezi toate elementele vectorului cu valoarea 0: v[i] = 0, cu i = 1..100
Pentru fiecare numar x citit (apartinand multimii 1..100), faci v[x] = 1
Pentru i de la 1 la 100, daca v[i] are valoarea 0 atunci afisezi v[i]
Regasim in codul lui emi:
# procedure init;
# begin
# for i := 1 to 100 do v[i] := false;
# end;
adica : Initializezi toate elementele vectorului cu valoarea 0: v[i] = 0, cu i = 1..100 (0/false... tot pe-acolo ca si functionalitate)
# for i := 1 to n do begin
# read(fin, t);
# v[t] := true;
# end;
vezi: Pentru fiecare numar x citit (apartinand multimii 1..100), faci v[x] = 1
# for i := 1 to 100 do begin
# if(v[i]=false) then begin
# write(i, ' ');
# nu_lipseste := false;
# end;
# end;
which means: Pentru i de la 1 la 100, daca v[i] are valoarea 0 atunci afisezi v[i] (corectat ulterior la v[i]... nu era o greseala majora...)
Pe scurt, tu nu ai reusit sa-ti dai seama ca cei doi algoritmi sunt _identici_ (bonus partea cu nu_lipseste, intr-adevar) - eu in locul tau as pune f serios mana pe carte (pardon, tastatura) pentru bac... desi daca e asa cum zici tu ca asta e subiectul cel greu (eu am dat fizica la bac pentru ca imi trebuia la admitere, recunosc ca nu stiu)...
Then I gave the analogy of a Greek scholar who loves the Greek language, who knows that in his own country there aren't many children studying Greek. But he comes to another country, where he is delighted to find everybody studying Greek--even the smaller kids in the elementary schools. He goes to the examination of a student who is coming to get his degree in Greek, and asks him, "What were Socrates' ideas on the relationship between Truth and Beauty?"--and the student can't answer. Then he asks the student, What did Socrates say to Plato in the Third Symposium?" the student lights up and goes, "Brrrrrrrrr-up"--he tells you everything, word for word, that Socrates said, in beautiful Greek. But what Socrates was talking about in the Third Symposium was the relationship between Truth and Beauty! (Richard Feynman vorbind despre Bac...)