• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            旅途

            如果想飛得高,就該把地平線忘掉

            面試系列1--返回整數中為1的位數

            ?原題:

            ? Write the function int bitCount(short input) that takes a short as input and
            ? returns an int.? The function returns the number of bits set in the input
            ? variable.? For instance:
            ? bitCount(7) --> 3
            ? bitCount(2543) --> 9
            ? bitCount(11111) --> 9

            代碼:

            /********************************************************************
            ??? created:??? 2006/06/14
            ??? created:??? 14:6:2006?? 16:53
            ??? filename:?? C:\Documents and Settings\Administrator\My Documents\近期閱讀\myTinyThing\bitCount.c
            ??? file path:? C:\Documents and Settings\Administrator\My Documents\近期閱讀\myTinyThing
            ??? file base:? bitCount
            ??? file ext:?? c
            ??? author:???? A.TNG
            ??? version:??? 0.0.1
            ???
            ??? purpose:??? 面試題
            ??????????????? Write the function int bitCount(short input) that takes a short as input and
            ??????????????? returns an int.? The function returns the number of bits set in the input
            ??????????????? variable.? For instance:
            ??????????????? bitCount(7) --> 3
            ??????????????? bitCount(2543) --> 9
            ??????????????? bitCount(11111) --> 9
            *********************************************************************/
            #include <stdio.h>

            /*
            ?*? name: bitCount
            ?*? params:
            ?*??? input???????? [in]??????? 需要分析的 short 型數
            ?*? return:
            ?*??? 輸入參數 input 的為1的位數
            ?*? notes:
            ?*??? 計算 input 中為1的位數
            ?*? author: A.TNG 2006/06/14 17:00
            ?*/
            int bitCount(short input)
            {
            ??? int n_ret?? = 0;

            ??? /* 只要 input 不為0,則循環判斷 */
            ??? while (0 != input)
            ??? {
            ??????? /* 如果 input & 1 == 1 則表示最低位為1,反之則等于0 */
            ??????? if (input & 1)
            ??????? {
            ??????????? n_ret++;
            ??????? }
            ??????? input = input >> 1;
            ??? }

            ??? return n_ret;
            }

            /*
            ?*? name: main
            ?*? params:
            ?*??? none
            ?*? return:
            ?*??? 函數返回狀態給系統
            ?*? notes:
            ?*??? 系統 main 函數
            ?*? author: A.TNG 2006/06/14 17:04
            ?*/
            int main()
            {
            ??? /* 輸入需要計算的整數 */
            ??? int n?? = 2543;

            ??? /* 輸出 bitCount 的結果 */
            ??? printf("%d\n", bitCount((short) n));

            ??? /* 發送 PAUSE 命令給系統 */
            ??? system("PAUSE");
            }

            posted on 2007-09-05 01:14 旅途 閱讀(123) 評論(0)  編輯 收藏 引用 所屬分類: C/C++

            久久99精品久久久久久久久久| 漂亮人妻被中出中文字幕久久 | AAA级久久久精品无码片| 久久免费99精品国产自在现线| 72种姿势欧美久久久久大黄蕉| 久久青草国产精品一区| 久久久久亚洲AV无码专区桃色 | 久久久一本精品99久久精品66| 97超级碰碰碰久久久久| 久久国产精品波多野结衣AV| 久久婷婷人人澡人人爽人人爱| 久久久久久亚洲Av无码精品专口| 久久精品免费观看| 久久无码AV中文出轨人妻| 丰满少妇高潮惨叫久久久| 亚洲色欲久久久久综合网| 久久婷婷国产综合精品| 国产高潮国产高潮久久久91 | 久久精品人人槡人妻人人玩AV| 大蕉久久伊人中文字幕| 日韩AV无码久久一区二区| 久久人妻少妇嫩草AV蜜桃| 99久久国产综合精品麻豆| 久久国产劲爆AV内射—百度| 国产国产成人久久精品| 久久精品毛片免费观看| 久久精品免费一区二区| 亚洲国产高清精品线久久| 国产精品欧美久久久久无广告 | 99热成人精品免费久久| 亚洲国产精品无码久久久不卡 | 久久免费线看线看| 97久久精品国产精品青草| 久久久久久久久久久久中文字幕 | 狼狼综合久久久久综合网| 久久久久久伊人高潮影院| 日日狠狠久久偷偷色综合96蜜桃| 久久成人永久免费播放| 国产视频久久| 无夜精品久久久久久| 伊人久久大香线蕉综合网站|