C++之指针

简单链表输入输出:

#include <iostream>
#include <cstdio>
using namespace std;
int a[100]; 
struct poi{
    int now;
    poi *next;
};
int main()
{
    poi *start;
    poi *now;
    now=NULL; 
    start=now;
    int i=0;
    poi *noww;
    while (++i<=10)
    {
        noww=new poi;
        noww->next=now;
        start=noww;
        now=noww;
        scanf("%d",&now->now);
    }
    printf("%d\n",start->now);
    now=start;
    while (now!=NULL)
    {
        printf("%d\n",now->now);
        now=now->next;
    }
} 

 

posted @ 2017-06-29 11:25  Michael_Zhuang  阅读(120)  评论(0编辑  收藏  举报