• <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>
            隨筆 - 62  文章 - 96  trackbacks - 0
            <2006年4月>
            2627282930311
            2345678
            9101112131415
            16171819202122
            23242526272829
            30123456

            常用鏈接

            留言簿(7)

            隨筆分類(66)

            隨筆檔案(62)

            文章分類(31)

            文章檔案(32)

            友情鏈接

            最新隨筆

            積分與排名

            • 積分 - 235656
            • 排名 - 108

            最新評(píng)論

            閱讀排行榜

            評(píng)論排行榜

            #include<cstdlib>
            #include<cstdio>
            int main() { int num = 10; char str[100]; itoa(num, str, 2); printf("%s\n", str); return 0; }
            itoa()函數(shù)有3個(gè)參數(shù):第一個(gè)參數(shù)是要轉(zhuǎn)換的數(shù)字,第二個(gè)參數(shù)是目標(biāo)字符串,第三個(gè)參數(shù)是轉(zhuǎn)移數(shù)字時(shí)所用 的基數(shù)。在上例中,轉(zhuǎn)換基數(shù)為10。10:十進(jìn)制;2:二進(jìn)制……
            于是想到了一個(gè)十進(jìn)制轉(zhuǎn)二進(jìn)制的方法:
            #include<cstdlib>
            #include<cstdio>
            int main() { int num = 10; char str[100]; int n = atoi(itoa(num, str, 2)); printf("%d\n",n); return 0; }
            先把num轉(zhuǎn)換為二進(jìn)制的字符串,再把該字符串轉(zhuǎn)換為整數(shù)。
            posted on 2006-10-12 00:59 beyonlin 閱讀(67456) 評(píng)論(14)  編輯 收藏 引用 所屬分類: acm之路 、C++之路

            FeedBack:
            # re: itoa函數(shù) 2006-10-23 23:45 Asp
            感覺很容易越界吧……  回復(fù)  更多評(píng)論
              
            # re: itoa函數(shù) 2006-10-24 00:33 beyonlin
            @Asp
            只是介紹一下STL函數(shù)的用法。
            那個(gè)str[100]只是一個(gè)例子~~  回復(fù)  更多評(píng)論
              
            # re: itoa函數(shù) 2007-07-11 08:52 小文
            第二個(gè)參數(shù)用string類型,可以嗎?  回復(fù)  更多評(píng)論
              
            # re: itoa函數(shù) 2007-07-11 09:49 AlanTop
            另一個(gè)10進(jìn)制轉(zhuǎn)二進(jìn)制的方法
            /*
            * 引用自 http://www.shnenglu.com/alantop/archive/2007/07/11/27845.html
            */
            // compile with: /EHsc
            #include
            #include

            int main( )
            {
            using namespace std;
            bitset<20> b1 ( 10 );
            cout << "The set of bits in bitset<5> b1( 10 ) is: ( "
            << b1 << " )." << endl;
            }
              回復(fù)  更多評(píng)論
              
            # re: itoa函數(shù) 2007-07-12 18:02 beyonlin
            @小文
            char* itoa(int, char*, int)
            第二個(gè)參數(shù)是char*,不能用string  回復(fù)  更多評(píng)論
              
            # re: itoa函數(shù) 2007-12-19 16:12 sakar2003
            itoa只是WINDOWS下面才有的函數(shù)吧,UNIX下面是沒有itoa的,跨平臺(tái)還是sprintf好  回復(fù)  更多評(píng)論
              
            # re: itoa函數(shù) 2008-08-01 11:33 sheena
            怎么第二個(gè)函數(shù)無(wú)法編譯呢。?
            int n = atoi(itoa(num, str, 2));

            n是不是還是應(yīng)該是當(dāng)初num 10 的值啊  回復(fù)  更多評(píng)論
              
            # re: itoa函數(shù) 2009-03-15 15:43 lai
            根本不是一回事。形似而質(zhì)不同。那樣轉(zhuǎn)換n的值都不在是10了。而是1010(十進(jìn)制)  回復(fù)  更多評(píng)論
              
            # re: itoa函數(shù) 2009-06-10 19:49 heh
            同意樓上。樓主水平確實(shí)不咋的  回復(fù)  更多評(píng)論
              
            # re: itoa函數(shù) 2009-10-28 10:22 snhnbn
            呵呵,太搞笑的十進(jìn)制轉(zhuǎn)二進(jìn)制了。莫非是二進(jìn)制的BCD碼?  回復(fù)  更多評(píng)論
              
            # re: itoa函數(shù) 2011-06-22 16:17 mxx
            @sheena
            絕對(duì)不是  回復(fù)  更多評(píng)論
              
            # re: itoa函數(shù) 2011-06-22 16:18 mxx
            樓主這個(gè)是在拋磚引玉,樓主自己寫出來(lái)的程序,他能不調(diào)試一下敢貼上來(lái)?他是為了讓大家思考,你看函數(shù)的參數(shù)描寫的多好!  回復(fù)  更多評(píng)論
              
            # re: itoa函數(shù) 2011-06-30 11:53 beyonlin
            @mxx
            謝謝你!  回復(fù)  更多評(píng)論
              
            # re: itoa函數(shù) 2012-11-29 17:54 腳步
            我用的是codeblocks的編譯器,為什么我的編譯器里沒有itoa函數(shù)?  回復(fù)  更多評(píng)論
              
            久久久久久精品成人免费图片| 国内高清久久久久久| 99久久精品无码一区二区毛片 | 国产欧美久久久精品影院| 日韩va亚洲va欧美va久久| 亚洲а∨天堂久久精品| 色综合久久久久久久久五月| 国产综合久久久久| 久久久久无码精品国产app| 99蜜桃臀久久久欧美精品网站| 久久亚洲精品成人AV| 久久精品国产福利国产琪琪| 看久久久久久a级毛片| 国产农村妇女毛片精品久久| 亚洲色大成网站www久久九| 99久久精品国产毛片| 人妻精品久久无码区| 久久婷婷五月综合97色直播| 久久久免费精品re6| 思思久久99热只有频精品66| 久久综合九色综合欧美狠狠| 久久综合久久自在自线精品自| 老司机午夜网站国内精品久久久久久久久 | 2020国产成人久久精品| 99久久99久久精品国产| 一级女性全黄久久生活片免费 | 狠狠色丁香婷婷久久综合| 93精91精品国产综合久久香蕉| 久久久精品2019免费观看| 91麻豆国产精品91久久久| 久久青青草原精品国产软件 | 少妇人妻综合久久中文字幕| 久久国产精品偷99| 99久久精品毛片免费播放| 久久久久青草线蕉综合超碰| 久久久久国产一区二区三区| 精品九九久久国内精品| 伊人久久综合成人网| 77777亚洲午夜久久多人| 亚洲国产日韩综合久久精品| 亚洲一级Av无码毛片久久精品|