#include <stdio.h>
/*const int ZERO = 0;
const int MAXLIMIT = 65535;*/
#define IS_CONTINUUM_5(n0,n1,n2,n3,n4) {\
int array[] = { n0, n1, n2, n3, n4 };\
printf( "\"%d %d %d %d %d\" IS %s\n",\
n0, n1, n2, n3, n4, is_continuum( array, 5, 0 ) ? "continuum" : "NOT continuum" ); }
int is_continuum( const int* nums, unsigned int len, int wildcard )
{
int minnum = nums[0];
int maxnum = nums[0];
unsigned int i;
for ( i = 1; i < len; ++ i )
{
if ( wildcard == nums[i] )
{
continue;
}
if ( nums[i] < minnum )
{
minnum = nums[i];
}
else if ( nums[i] > maxnum )
{
maxnum = nums[i];
}
}
return ( ( maxnum - minnum ) < len );
}
void test0()
{
/*positive*/
IS_CONTINUUM_5(1,2,3,4,5)
IS_CONTINUUM_5(3,0,4,1,5)
IS_CONTINUUM_5(34,0,32,33,0)
IS_CONTINUUM_5(0,0,0,0,0)
/*negative*/
IS_CONTINUUM_5(1,0,8,0,0)
IS_CONTINUUM_5(1,2,3,4,6)
IS_CONTINUUM_5(234,284,20,1234,59245)
IS_CONTINUUM_5(0,9,4,8,7)
}
typedef void ( *testproc_type )();
testproc_type tests[] =
{
test0
};
int main()
{
int i;
for ( i = 0; i < sizeof( tests ) / sizeof( tests[0] ); ++ i )
{
tests[i]();
}
return 0;
}
/* end of source */