# A代码填空题--更换火车头

A代码填空题--更换火车头

c：

#include <stdio.h>
struct Train
{
int num;
Train *next;
};
Train *creat(int n){
Train *t=new Train;
scanf("%d",&t->num) ;
if(n==1){
t->next = NULL;
return t;
}
t->next = creat(n-1);
return t;
}
void print(Train *p){
if(p==NULL)
return ;
printf("%d ",p->num);
print(p->next);
}
void del(Train *p){
if(p==NULL)
return ;
Train *t;
t=p->next;
delete p;
del(t);
}
Train *rev(Train *p){
while(p)    {
t=p->next;
/*******************************
请在该部分补充缺少的代码
********************************/
}
}
int main(void)
{
int n;
Train *rev(Train *p);
scanf("%d",&n);
return 0;
}

c++：

#include <iostream>
using namespace std;
struct Train {
int num;  //人数
Train *next;
};
Train *creat(int n)
{
Train *t=new Train;
cin>>t->num ;
if(n==1) {
t->next = NULL;
return t;
}
t->next = creat(n-1);
return t;
}
void print(Train *p){
if(p==NULL)
return ;
cout<<p->num<<" ";
print(p->next);
}
void del(Train *p)
{
if(p==NULL)
return ;
Train *t;
t=p->next;
delete p;
del(t);
}
Train *rev(Train *p)
{
while(p){
t=p->next;
/*******************************
请在该部分补充缺少的代码
********************************/
}
}

int main(void)
{
int n;
Train *rev(Train *p);
cin>>n;
return 0;
}

``````10
110 112 108 100 118 100 60 64 56 62``````

``62 56 64 60 100 118 100 108 112 110``

``````#include<stdio.h>
int main()
{
int n,i;
scanf("%d",&n);
int a[n];
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=n-1;i>=0;i--)
{
printf("%d",a[i]);
if(i==0)break;
printf(" ");
}

return 0;
}
``````

``````
#include <iostream>
using namespace std;
struct Train {
int num;  //
Train *next;
};
Train *creat(int n)
{
Train *t=new Train;
cin>>t->num ;
if(n==1) {
t->next = NULL;
return t;
}
t->next = creat(n-1);
return t;
}
void print(Train *p){
if(p==NULL)
return ;
cout<<p->num<<" ";
print(p->next);
}
void del(Train *p)
{
if(p==NULL)
return ;
Train *t;
t=p->next;
delete p;
del(t);
}
Train *rev(Train *p)
{
while(p){
t=p->next;
p = t;
}
}

int main(void)
{
int n;