#include<stdio.h>
#include<stdlib.h>
typedef int elementtype;
struct Node;
typedef struct Node *PtrToNode;
typedef PtrToNode List;
typedef PtrToNode Position;
typedef struct Node
{
int element;
struct Node *next;
}Node;
void printout(Position p,List L)
{
p=L->next;
while(p!=NULL)
{
printf("%d ",p->element);
p=p->next;
}
}
int main()
{
Node *m,*n,*L;
Position a;
int i,j,k;
printf("How many numbers in list L?\n");
scanf("%d",&k);
L=(Node * )malloc(sizeof(Node));
L->next=NULL;
m=L;
for(i=0;i<k;i++)
{
n=(Node * )malloc(sizeof(Node));
printf("please input the %dth number: ",i+1);
scanf("%d",&j);
n->element=j;
n->next=m->next;
m->next=n;
m=m->next;
}
printout(a,L);
printf("\n");
return 0;
}
my presentation2
最新推荐文章于 2024-08-10 04:06:41 发布