hankyoのプロフィール
- ベストアンサー数
- 0
- ベストアンサー率
- 0%
- お礼率
- 80%
- 登録日2005/05/17
- リス;ト構造のポインタ
struct list{ int data; struct list *next; }; struct list *cons(int x,struct list *n){ struct list *ans; ans=(struct list*)malloc(sizeof(struct list)); if(ans!=null) ans->date=x; ans->next=n; } return ans;} void main(){ int x; struct list *top=NULL; struct list **tail=⊤ while(scanf("%d",&x)==1){ *tail=cons(x,NULL); tail=&((*tail)->next): } 入力した順にリストに追加されるプログラムらしいのですが、void main(){}の中のプログラムの動きが よく分かりません。このプログラムの動作の流れを簡単に教えてください。漠然とした質問カと思いますが よろしくお願いします。
- リス;ト構造のポインタ
struct list{ int data; struct list *next; }; struct list *cons(int x,struct list *n){ struct list *ans; ans=(struct list*)malloc(sizeof(struct list)); if(ans!=null) ans->date=x; ans->next=n; } return ans;} void main(){ int x; struct list *top=NULL; struct list **tail=⊤ while(scanf("%d",&x)==1){ *tail=cons(x,NULL); tail=&((*tail)->next): } 入力した順にリストに追加されるプログラムらしいのですが、void main(){}の中のプログラムの動きが よく分かりません。このプログラムの動作の流れを簡単に教えてください。漠然とした質問カと思いますが よろしくお願いします。