#include "stdafx.h"
#define N 5
void reverse(int a[],int n );
int main(int argc, char* argv[])
{
int number,a[N],i = 0;
printf("请输入一位5位正整数: ");
scanf("%d",&number);
do{
a[i++] = number % 10;
}while((number /= 10) > 0);
reverse(a,N);
for(i = 0;i < N;i++)
printf("a[%d] = %d\n",i,a[i]);
return 0;
}
void reverse(int a[],int n )
{
int i,j,*ptr1,*ptr2,temp;
ptr1 = a;
ptr2 = a + n - 1;
for(i = 0,j = n - 1;i < j;i++,j--)
{
temp = *ptr1;
*ptr1 = *ptr2;
*ptr2 = temp;
ptr1++,ptr2--;
}
}