#include<stdio.h>
#include<stdlib.h>
struct Node;
typedef struct Node *PtrToNode;
typedef PtrToNode List;
typedef PtrToNode Position;

struct Node{
    int  Ele;
    Position Next;
};
void
PrintArray(List L)
{
    Position p;
    p = L;
    while( p->Next != NULL )
    {
        printf("%d",p->Next->Ele);
        p = p->Next;
    }
}
Position
CreateTable( void )
{
    PtrToNode L;
    L = malloc( sizeof( struct Node ) );
    if( L == NULL){
        printf("out of space ");
        return ;
    }
    L->Next = NULL;
    return L;
}

int main()
{

    int i;
    Position L,p;
    PtrToNode TmpCell;
    L = CreateTable();
    p = L;
    for(i = 0; i<3; i++ )
    {
        TmpCell = malloc(sizeof(struct Node ));
        if(TmpCell == NULL)
        {
            printf("error");
            return;
        }
        p->Next = TmpCell;

        TmpCell->Ele = i;
        TmpCell->Next = NULL;

        p = TmpCell;
    }
    PrintArray( L );
}
View Code

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-05
  • 2022-12-23
  • 2021-11-11
  • 2022-12-23
  • 2021-07-21
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-18
相关资源
相似解决方案