• <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 旅途 閱讀(122) 評論(0)  編輯 收藏 引用 所屬分類: C/C++

            国产精品xxxx国产喷水亚洲国产精品无码久久一区 | 午夜精品久久久久9999高清| 欧美激情精品久久久久| 国产高潮久久免费观看| 亚洲午夜无码AV毛片久久| 人妻精品久久久久中文字幕69| 久久久av波多野一区二区| 国内精品久久久久久不卡影院| 精品熟女少妇AV免费久久| 国内精品伊人久久久久影院对白| 久久夜色精品国产亚洲| 热99re久久国超精品首页| 久久婷婷国产剧情内射白浆| 品成人欧美大片久久国产欧美| 亚洲伊人久久大香线蕉综合图片| 久久这里只有精品首页| 少妇人妻88久久中文字幕| 无码人妻久久一区二区三区蜜桃| 久久精品国产91久久综合麻豆自制| 久久精品无码一区二区WWW| 久久精品国产亚洲Aⅴ蜜臀色欲| 国产午夜免费高清久久影院| 2021国产精品久久精品| 久久亚洲中文字幕精品一区四 | 欧美激情精品久久久久久久九九九 | 亚洲欧美日韩中文久久| 久久人人爽人人精品视频| 久久综合综合久久狠狠狠97色88| yy6080久久| 色狠狠久久综合网| 亚洲精品tv久久久久| 久久精品成人| 久久久黄片| 久久亚洲国产精品123区| 狠狠色伊人久久精品综合网| 日韩亚洲欧美久久久www综合网 | 久久精品国产2020| 久久久久久曰本AV免费免费| 天天影视色香欲综合久久| 久久久精品久久久久特色影视| 国产精品亚洲美女久久久|