Dsy Network www | forum | my | didattica | howto | wiki | el goog | stats | blog | dona | rappresentanti
Homepage
 Register   Calendar   Members  Faq   Search  Logout 
.dsy:it. : Powered by vBulletin version 2.3.1 .dsy:it. > Community > Tech > [c] cancellazione elementi selezionati
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
maynard80
.novellino.

User info:
Registered: Jul 2007
Posts: 3 (0.00 al dì)
Location: Milano (e non interland, tendo a precisare)
Corso: informatica
Anno: SESTO
Time Online: 12 Days, 14:28:38 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
[c] cancellazione elementi selezionati

ragazzi scusate sono nel pallone, mi dite come cancellare gli elementi di una lista?

la liste è formata da nodi del tipo

struct nodo{
int x;
int y;
struct nodo *next;
}

voglio cancellare dalla lista tutti i nodi la cui x è n

nodo *cancellaSelezionati(*struct nodo head, int n);

storincoglionendo,pleaseee!

__________________
msn Messenger: giamma80 at tiscali.it
ATHENA !

30-09-2005 18:27
Click Here to See the Profile for maynard80 Click here to Send maynard80 a Private Message Find more posts by maynard80 Add maynard80 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
Skilotto83
..Energia positiva...

User info:
Registered: Jun 2003
Posts: 1608 (0.20 al dì)
Location: Arconate
Corso: Informatica
Anno: LAUREATO!!!
Time Online: 15 Days, 6:32:44 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

boh...metti il puntatore dell'elemento n-esimo della lista a null...
Una roba del genere...

__________________
"Why, Sir, you find no man at all intellectual who is willing to leave London.
No, Sir, when a man is tired of London, he is tired of life; for there is in London all that life can afford."
(DR SAMUEL JOHNSON 1777)

MSN andrea.poretti(at)hotmail.it

30-09-2005 19:39
Click Here to See the Profile for Skilotto83 Click here to Send Skilotto83 a Private Message Find more posts by Skilotto83 Add Skilotto83 to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
yeah
.grande:maestro.

User info:
Registered: Nov 2003
Posts: 1644 (0.21 al dì)
Location: Cologno Monzese
Corso: Informatica Magistrale
Anno: II
Time Online: 12 Days, 21:36:41 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

code:
nodo *cancella_selezionati(struct nodo *head, int n) { struct nodo *found; while(head->next) if(head->next->x == n) { found = head->next; head->next = head->next->next; free(found); } return head; /* o cur... non so cosa possa essere più utile */ }


Due considerazioni:
- inizia il controllo dal secondo nodo in lista; questo è un problema derivante dal fatto che non ho ancora trovato un modo per gestire il primo elemento di una lista concatenata.
- non ritorna niente di utile, visto che può cancellare 0 o più nodi


Tutto questo assolutamente non testato :D

[edit] Manca qualcosa...
[edit2] Ora dovrebbe esserci tutto...
[edit3]No, ci sono degli errori...
[edit4]Ora dovrebbe essere a posto :)

__________________
?

Last edited by yeah on 30-09-2005 at 20:22

30-09-2005 19:55
Click Here to See the Profile for yeah Click here to Send yeah a Private Message Find more posts by yeah Add yeah to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
DeepBlue
tired guy

User info:
Registered: Sep 2003
Posts: 4258 (0.54 al dì)
Location: CSN
Corso: Info tlc
Anno:
Time Online: 52 Days, 8:40:31 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

queste slide potrebbero tornarti molto utili:

http://www.di.unipi.it/~gori/Inform...i/Lezione14.pdf

__________________
~ get Debian! ~ get FreeBSD! ~ get OpenBSD! ~

30-09-2005 20:27
Click Here to See the Profile for DeepBlue Click Here to See the Blog of DeepBlue Click here to Send DeepBlue a Private Message Find more posts by DeepBlue Add DeepBlue to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
yeah
.grande:maestro.

User info:
Registered: Nov 2003
Posts: 1644 (0.21 al dì)
Location: Cologno Monzese
Corso: Informatica Magistrale
Anno: II
Time Online: 12 Days, 21:36:41 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

Vedo che in quelle slide si usa la seconda delle due possibilità:
- oggetto 'finto': serve da testa della lista, non memorizza nessun valore;
- puntatore: la lista è iniziata da un puntatore

Personalmente il problema con il secondo tipo è che (primo esempio che mi viene in mente) nel caso:

[ptr] -> [el1] ->[el2]

per eliminare el1 bisogna tener conto del fatto che a sinistra c'è solo un puntatore e non un elemento completo.

Cmq rileggerò le slide con più attenzione :) Grazie

__________________
?

01-10-2005 01:36
Click Here to See the Profile for yeah Click here to Send yeah a Private Message Find more posts by yeah Add yeah to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 19:55.    Post New Thread    Post A Reply
  Last Thread   Next Thread
Show Printable Version | Email this Page | Subscribe to this Thread | Add to Bookmarks

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

Powered by: vBulletin v2.3.1 - Copyright ©2000 - 2002, Jelsoft Enterprises Limited
Mantained by dsy crew (email) | Collabora con noi | Segnalaci un bug | Archive | Regolamento | Licenze | Thanks | Syndacate
Pagina generata in 0.055 seconds (71.00% PHP - 29.00% MySQL) con 25 query.