万金流
初次使用博客园,目前感觉还不错。 不知不觉用了4年零4个月了,越来越喜欢博客园。

代码:

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
struct Node
{
    int v;
    Node *next;
};
main()
{
    int n;
    Node *a=new Node,*b;
    cin>>n;
    b=a;
    cin>>a->v;
    a->next=NULL;
    for(int i=2;i<=n;i++)
    {
        a->next=new Node;
        a=a->next;
        cin>>a->v;
        a->next=NULL;
    }
    a=b;
    do
    {
        cout<<a->v<<endl;
        a=a->next;
    }
    while(a!=NULL);
}

 

posted on 2019-08-23 14:45  万金流  阅读(656)  评论(0编辑  收藏  举报