// ConsoleApplication5.cpp : 定义控制台应用程序的入口点。
//
#include <iostream>
#include <stdlib.h>
using namespace std;
typedef struct Node{
int data;
Node *next;
};
int main(){
int n;
cin >> n;
Node *head, *p;
head = (Node *)malloc(sizeof(Node));
head->next = NULL;
p = head;
int m = n;
while (n){
p = (Node *)malloc(sizeof(Node));
cin >> p->data;
p->next = head->next;
head->next = p;
n--;
}
p = head->next;
while (m)
{
cout << p->data << " ";
p = p->next;
m--;
}
return 0;
}
网友评论