You can't define reverse
inside of main
like that. Move it out separate from main, something on this general order:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int reverse(int o,int k,int* p){
temp = *(p+k);
*(p+k)=*(p+o);
*(p+o) = temp;
o=o-1;k=k+1;
if(o==k)
{
return 0;
}
else if((k+1)==o){
temp = *(p+k);
*(p+k)=*(p+o);
*(p+o) = temp;
return 0;
}
else{
reverse(o,k,p);
}
}
int main() {
int temp,n,i;
scanf("%d",&n);
int a[n];
for(i=0;i<n;i++)
scanf("%d",&a[i]);
int y = reverse(n,(int)0,&a[0]);
for(i=0;i<n;i++)
printf("%d",a[i]);
return 0;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…