求一个C算法
c吧
全部回复
仅看楼主
level 1
光速兔仔 楼主
有一个unsigned char a和一个unsigned long b,
当a=0时,b=0
当a!=0时,b=0xFF FF FF FF(unsigned long类型的最大值)
要求:不得使用任何条件分支语句(包括if,:? 等)
谢谢
2009年09月22日 16点09分 1
level 1
#include "stdio.h"
main()
{   
unsigned  char a;
unsigned  long b;
long c=-1;
scanf("%c",&a);
b=c+(a==0);
printf("%lu",b);
getch();
}
2009年09月23日 02点09分 2
level 1
D
2009年09月24日 11点09分 3
level 1
D
2009年09月24日 11点09分 4
1