如何求数组中所有可能的元素和
例123 687 -785 542
程序代码:#include <stdio.h>
int main( void )
{
const int a[] = { 123, 687, -785, 542 };
for( unsigned m=1; m!=1u<<4; ++m )
printf( "%d\n", ((m&1)!=0)*a[0] + ((m&2)!=0)*a[1] + ((m&4)!=0)*a[2] + ((m&8)!=0)*a[3] );
return 0;
}输出