• <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,則循環(huán)判斷 */
            ??? while (0 != input)
            ??? {
            ??????? /* 如果 input & 1 == 1 則表示最低位為1,反之則等于0 */
            ??????? if (input & 1)
            ??????? {
            ??????????? n_ret++;
            ??????? }
            ??????? input = input >> 1;
            ??? }

            ??? return n_ret;
            }

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

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

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

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

            亚洲午夜久久影院| 久久人与动人物a级毛片| 午夜精品久久久久久影视777| 久久综合狠狠综合久久综合88 | 亚洲AV无码久久精品色欲| 久久久久久精品免费看SSS| 久久精品国产第一区二区三区| 国产成人精品综合久久久| 蜜桃麻豆www久久国产精品| 欧美噜噜久久久XXX| 久久国产成人午夜AV影院| 怡红院日本一道日本久久| 热99RE久久精品这里都是精品免费 | 色综合久久久久无码专区| 国产精品久久久久久搜索| 无码国内精品久久人妻麻豆按摩| 人妻无码αv中文字幕久久琪琪布| 91精品国产综合久久四虎久久无码一级 | 国产精品无码久久综合| 亚洲v国产v天堂a无码久久| 国产精品无码久久久久久| 久久精品国产亚洲AV香蕉| 久久se这里只有精品| 国产亚洲欧美成人久久片| 久久久久久久免费视频| 中文字幕一区二区三区久久网站| 色欲av伊人久久大香线蕉影院| 99久久精品免费国产大片| 99久久777色| 久久久久亚洲av无码专区| 亚洲精品乱码久久久久久自慰| 欧美国产精品久久高清| 国产精品久久久99| 久久精品一区二区国产| 91精品国产综合久久久久久| 久久精品国产亚洲AV香蕉| 久久久久久伊人高潮影院| 亚洲国产一成久久精品国产成人综合| 99久久精品免费看国产| 久久久久久国产精品美女| 欧美久久久久久精选9999|