PDA

View Full Version : ordinare array int c++


GTech
24-02-2013, 19:04
ciao a tutti. oggi mi hanno dato un esercizio con cui non ne do fuori.

Si tratta di, inseriti con il cin i numeri in un array, trovare il modo per ordinarli...

io ho trovato il modo per il minimo e max ma non so come ordinarli!!!

HoldenCaulfield1987
24-02-2013, 19:44
Se hai già del codice postalo o spiega la tua idea.

Comunque dovresti utilizzare un qualche algoritmo di ordinamento.
Il Bubble Sort ad esempio andrebbe benissimo e si implementa molto facilmente.

GTech
24-02-2013, 20:31
calcola che sono alle superiori e lo facciamo molto in maniera superficiale...cos'è il Bubble Sort? pensavo di fare con u for e qualche if visto che sono le uniche cose che ci hanno spiegato..:confused: :confused:

HoldenCaulfield1987
24-02-2013, 20:43
Il bubble sort è un algoritmo di ordinamento basato su confronti.
Questo ti aiuterà: http://it.wikipedia.org/wiki/Bubble_sort

GTech
24-02-2013, 20:45
mi sembra complicato... lo posso fare con solo if e for?

HoldenCaulfield1987
24-02-2013, 20:48
Si.
C'è un esempio in pseudocodice (molto simile al c++).
Prova a implementarlo e se hai problemi chiedi. :)

Hardware Upgrade Forum Database Error
Database Error Database error
The Hardware Upgrade Forum database has encountered a problem.

Please try the following:
  • Load the page again by clicking the Refresh button in your web browser.
  • Open the www.hwupgrade.it home page, then try to open another page.
  • Click the Back button to try another link.
The www.hwupgrade.it forum technical staff have been notified of the error, though you may contact them if the problem persists.
 
We apologise for any inconvenience.