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. > Didattica > Corsi N - Z > Programmazione > [nomeDelCorso???] Liste concatenate
  Last Thread   Next Thread
Author
Thread    Expand all | Contract all    Post New Thread    Post A Reply
Collapse
fabione
.amico.

User info:
Registered: Nov 2003
Posts: 33 (0.00 al dì)
Location: milano
Corso: informatica per le telecomunicazioni
Anno: 4FC
Time Online: 16:51:02: [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
Unhappy Liste Concatenate Inserimento Di Un Elemento

Ragazzi sono in panico,vorrei inserire un elemento nella mia lista qualcuno saprebbe aiutarmi,devo riuscire a fare puntare p1 al primo elemento della lista(che sarebbe 'g') e p2 al secondo elemento(che sarebbe 'i') , q invece deve puntare all'elemento della lista esterna('t'), di modo che possa eseguire void insert(LINK p1,LINK p2,LINK,q).
ecco il codice:


#include "lista1.h" /* l'header è a posto */
#include <stdio.h>
#include <stdlib.h>
int count(LINK head);
void insert(LINK p1,LINK p2,LINK q);
main()
{
LINK head,heads,p1,p2,q;
head=malloc(sizeof(ELEMENT));
head->d='g'; /* creo una lista di un 1EL*/
head->next=NULL;

head->next=malloc(sizeof(ELEMENT));
head->next->d='i'; /* aggiungo un secondo el */
head->next->next=NULL;

head->next->next=malloc(sizeof(ELEMENT));
head->next->next->d='o'; /* aggiungo un terzo EL*/
head->next->next->next=NULL;

heads=malloc(sizeof(ELEMENT));
heads->e='t'; /* creo una lista separata */
heads->next=NULL;

p1=&head->d;
p2=&head->next->d; /* MI PUZZA DI STRO
q=&heads->e; CONFERMATE? */

printf("%c\n%c\n%c",head->d,head->next->d,head->next->next->d);
printf("\nla mia lista separata cont: %c\n",heads->e);
printf("\nLe occorenze sono: %d\n",count(head)); /* stampo gli elem*/
}
int count(LINK head)
{
if(head==NULL)
return 0; /* definizione della funzione count */
else
return(1+count(head->next));
}

void insert(LINK p1,LINK p2,LINK q)
{
p1->next=q;
q->next=p2;
}

19-01-2004 17:22
Click Here to See the Profile for fabione Click here to Send fabione a Private Message Find more posts by fabione Add fabione 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
Re: Liste Concatenate Inserimento Di Un Elemento

E' già abbastanza difficile dare delle risposte sul C :rolleyes:, se poi non posti nemmeno il codice direi che è quasi impossibile :rolleyes:
Cos'è LINK? Una struct immagino...ma come l'ha definita?

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

19-01-2004 20:14
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
Berserk
elfucker

User info:
Registered: Jul 2002
Posts: 477 (0.06 al dì)
Location:
Corso: Informatica
Anno: out-of-date
Time Online: 3 Days, 17:29:15 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged

dovresti usare delle variabili di tipo link che fanno le operazioni sulla lista senno'perdi il puntatore...

__________________
"Non puo' piovere per sempre".....cazzo saro'mica nato in Amazonia!!!

L'amazonia e' un bel posto, ma preferisco il paradiso :D

Membro ufficiale della F.I.A.E. Federazione Italiana Anti Elfo

19-01-2004 21:02
Click Here to See the Profile for Berserk Click here to Send Berserk a Private Message Find more posts by Berserk Add Berserk to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
Collapse
deadMe
.:pollo smidollato:.

User info:
Registered: Dec 2003
Posts: 312 (0.04 al dì)
Location: Pleasentville
Corso: informatica per le telecomunicazioni
Anno: manca poco, manca poco
Time Online: 2 Days, 9:31:34 [...]
Status: Offline

Post actions:

Edit | Report | IP: Logged
lista1.h

Ti sei dimenticato di dire qual'è il problema: se ti da un errore, se non lo fa giusto, etc...

cmq manda il codice di lista1.h

26-01-2004 16:10
Click Here to See the Profile for deadMe Click here to Send deadMe a Private Message Find more posts by deadMe Add deadMe to your buddy list Printer Friendly version Email this Article to a friend Reply w/Quote
All times are GMT. The time now is 23:45.    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.059 seconds (56.30% PHP - 43.70% MySQL) con 25 query.