//两个int类型的数据,不用任何的判断语句如if、switch、?:等,找出其中的大值
#include <stdio.h>
/*
int
max( int x,int y )
{
int buf[2] = { x, y };
unsigned int z;
z = x - y;
z >>= 31;
return buf[z];
}
*/
int
max( int x,int y )
{
int buf[2]={x,y};
unsigned int z;
int c;
z = x - y;
c = x - y;
z >>= 31;
z= 0 ^ z;
return buf[z];
}
int
main( int argc, char *argv[] )
{
int buf[2];
if( argc != 3 )
{
printf( "USEG error" );
return -1;
}
buf[0] = atoi(argv[1]);
buf[1] = atoi(argv[2]);
printf( "The max num is %d\n", max( buf[0], buf[1] ) );
return 0;
}