#include <stdio.h> #include <math.h> #include <stdlib.h> void main() { int *p; int min,ca,n,i,j; scanf("%d",&n); p = ( int * )malloc( n*sizeof( int ) ); if ( p == NULL ) { printf("分配内存失败/n"); exit( EXIT_FAILURE ); } for ( i=0; i<n; i++ ) scanf("%d",p+i); min = fabs( *p-*(p+1) ); for ( i=0 ; i<n-1; i++ ) { for ( j=i+1; j<n; j++ ) { ca = fabs( *(p+i)-*(p+j) ); if ( ca < min ) { min = ca; if ( min == 0 ) break; } } } printf("%d/n",min); free( p ); exit( EXIT_SUCCESS ); }