close

#include
#include

using namespace std;

int Bin2Dec( char* s  , int r )
{
        //遞回寫法N進位轉十進位
    if( s[0]=='0' )
    return 0;
    int n = strlen(s);
        //計算自串長度
    int x = s[n-1]-'0';
        //某數字內碼-0的內碼得到該數值
    s[n-1]='\0';
        //於字串中取出後,命令該位數為空字元
    return Bin2Dec(s,r)*r+x;
        //還原字串內容
}
int main()
{
   char bin[30];
   int r;
   cout >bin;
   cout >r;
   cout    return 0;
}

全站熱搜
創作者介紹
創作者 alex2008 的頭像
alex2008

alex2008的部落格

alex2008 發表在 痞客邦 留言(1) 人氣()