Λιγο βοήθεια με τη C

Chameleon cham_gss at hotmail.com
Fri Jun 2 17:56:35 EEST 2006


Σήμερα είμαι ξεμέθυστος...

>> Auto poy xrhsimopoieis einai C++
>> an 8eleis C sketh, xrhsimopoihse printf anti gia cout.
>>
> 
> C++ rulez, apla i C einai voliki ores ores

...παρόλα αυτά, αυτό δεν το καταλαβαίνω.

>> Anti na xrhsimopoieis auto to blakwdes algori8mo ta3inomhshs, 
>> xrhsimopoihse quick sort.
>>
> 
> Den einai vlakodes o algorithmos taxinomisis, giati den einai provlima
> aftos...

Βάλε να ταξινομηθούν 1000 (μόνο) elements.


>> Den xreiazetai na ton ylopoihseis. yparxei etoimos sthn ANSI C.
>>
>> apo to MSDN:
> 
> LINUX!

ok. όπως σε βολεύει.


>> ----------------------
>> Performs a quick sort.
>>
>>
>> void qsort(
>>     void *base,
>>     size_t num,
>>     size_t width,
>>     int (__cdecl *compare )(const void *, const void *)
>> );
>>
>>
>>
>> Parameters
>> base
>> Start of target array.	****** matrix
>>
>> num
>> Array size in elements.	****** sizeof( matrix )/sizeof( matrix[0] )
>>
>> width
>> Element size in bytes.	****** sizeof double
>>
>> compare
>> Comparison function. The first parameter is a pointer to the key for the
>> search and the second parameter is a pointer to the array element to be
>> compared with the key.
>> -----------------------
>>
>> prepei na ylopoihseis mia synarthsh poy na elegxei tous dyo double.
>> (mesw pointer o elegxos)
>>
>>
>>
>>
>>
>> An telika to 8eleis se C++ xrhsimopoihse ena map<double, int>. Auto den
>> 8elei kan ta3inomhsh.
>>
> 
> STL? ox!

Γιατί ωχ; Το map είναι κάτι σαν array, μόνο που για indices θα έχεις 
αριθμούς double.

δηλαδή:
this_is_a_map[15.123] = this_is_a_map[15.123] + 1;

>> An to 8eleis se C, gia kalytera, ta3inomhse ta kai meta kane ena struct
>> san ki auto:
>>
>> struct {
>> 	double key;
>> 	int freq;
>> } map_element;
>>
> 
> Diladi na tsekaro se kathe key, an ehei bei se proigoumeno key o arithmos
> pou tha theso...kai i antistixi sixnotita emfanisis...

Ακριβώς. Και εφόσον θα είναι ταξινομημένα, θα το τσεκάρεις με binary search.

>> mporeis na epistrefeis ena pointer se array apo map_element apo thn
>> freq_array. Prepei na kaneis allocation mesa sth freq_array kai
>> deallocation ektos auths. Auto den einai kalh texnikh programmatismoy.
>> Protimhse na kaneis allocation sthn main me osa stoixeia exei to arxiko
>> array (ektos ki an 3ereis kati allo gia thn poikilia twn stoixeiwn) kai
>> deallocation pali sth main (den 8a exoun xrhsimopoih8ei ola ta stoixeia
>> tou neou array pi8anon)
>>
>>
>> Asxeto, alla eisai ligo off-topic.
>> dokimase to comp.lang.c h comp.lang.c++ h akoma kalytera to
>> alt.comp.lang.learn.c-c++
>>
>>
> 
> Eixa kairo na kano ena post edo... :-)

Δεν σε ξέρω.
Καλύτερα παντως να στέλνεις εκεί γιατί εκεί δεν είναι off-topic.
Δεν σε μαλώνω, να βοηθήσω θέλω.
(Άλλωστε εκεί μπαίνει πολύς κόσμος ενώ εδώ μόνο Έλληνες).



More information about the Linux-greek-users mailing list