/*
静态链表
@author by Rice
*/
#include <iostream>
using namespace std;
struct Lnode{
int data;
char name[10];
struct Lnode *next;
};
int main(){
struct Lnode a,b,c,*p,*Head;
int x;
//初始化
Head = NULL;
Head = &a;
a.next = &b;
b.next = &c;
c.next = NULL;
p = Head;
//创建
while(p!=NULL){
scanf("%d",&x);
p->data = x;
p = p->next;
}
//输出
p = Head;
while(p!=NULL){
printf("%d\n",p->data);
p = p->next;
}
return 0;
}
网友评论