-5
왜 이것이 작동하지 않는지 모르겠다.연결된 목록 포인터 prob
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
// struct of list
typedef struct noeud
{
int adresse, taille, temp;
struct noeud* suivant;
} * liste;
int random(int a, int b)
{
return (a + (rand() % ((b + 1) + a)));
}
void initialisation(liste* LBO)
{
*LBO = NULL;
}
은 내가 q
(q
는 이전 노드를 가리 키도록 작성)을 만들 때 문제는 여기에 생각합니다.
void creation(liste* LBO)
{
liste q, prec = NULL;
int i = 0;
srand(time(NULL));
while (i < 3)
{
printf("%d", i);
q = malloc(sizeof(liste));
if (*LBO == NULL)
{
q->adresse = 0;
q->taille = random(5, 45);
q->temp = random(5, 15);
q->suivant = *LBO;
*LBO = q;
i++;
}
else
{
prec = *LBO;
q->taille = random(5, 45);
q->temp = random(5, 15);
q->adresse = prec->adresse + prec->taille;
q->suivant = *LBO;
*LBO = q;
i++;
}
}
}
void affichage(liste LBO)
{
printf("\nvoici ta liste \n ");
while (LBO != NULL)
{
printf("%d-->", LBO->taille);
LBO = LBO->suivant;
}
if (LBO == NULL)
printf("NULL");
}
int main()
{
// or here
printf("Hello world!\n");
liste LBO;
initialisation(&LBO);
creation(&LBO);
affichage(LBO);
return 0;
}
이 심각한 편집을 필요가있다,
<<<<<<<<<<<
로 의견 봐. 나는 노력했지만 포기했다. – unwind디버거를 사용하여 문제의 원인을 찾으십시오. 이 문제를 해결하려면 먼저 무엇이 무엇인지 알아야합니다. – Yousaf
C 교과서의 샘플처럼 들여 쓰기 (형식 지정)하십시오. –