摘要:
1.Count1InAInteger()用来计算某一个数中1的个数,使用求余,然后再main中循环调用,但效率不高 1 #include <iostream> 2 using namespace std; 3 4 unsigned long Count1InAInteger(unsigned long n) 5 { 6 unsigned long iNum = 0; 7 while(n != 0) 8 { 9 iNum += (n % 10 == 1) ? 1 : 0;10 n /= 10;11 }12 return iNum;13 }14 15 unsigned long mai 阅读全文
posted @ 2011-04-08 15:37
lazycoding
阅读(847)
评论(0)
推荐(2)

浙公网安备 33010602011771号