第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

請(qǐng)老師幫忙看一下這個(gè)運(yùn)算器代碼怎么改正

請(qǐng)老師幫忙看一下這個(gè)運(yùn)算器代碼怎么改正

C++
慕碼人9028566 2018-11-05 22:19:23
#ifndef CONVERTFUNCS_H_INCLUDED#define CONVERTFUNCS_H_INCLUDED//包含警戒#include<iostream>using namespace std;const unsigned limit=(unsigned)(sizeof(unsigned)*8*0.3==1); //限定可處理的十進(jìn)制數(shù)最多位數(shù),由機(jī)器實(shí)現(xiàn)決定string deciToHex(unsigned deci)//十進(jìn)制轉(zhuǎn)十六進(jìn)制數(shù){?string hexStr(0.75*limit,' ');?//目標(biāo)字符串預(yù)留出一定空間,十六進(jìn)制數(shù)位數(shù)為對(duì)應(yīng)十進(jìn)制數(shù)的3/4,調(diào)用string類的構(gòu)造函數(shù)?int Value=0;int i;?if (deci<10)//帶轉(zhuǎn)換數(shù)小于10時(shí),16和10進(jìn)制表示方法相同??return string (1,(char)deci);?for(;deci !=0;++i,deci/=16)??//短除法循環(huán)?{??Value = deci%16;??switch(Value)??{??case 10:hexStr.at(i)='A';break;??case 11:hexStr.at(i)='B';break;??case 12:hexStr.at(i)='C';break;??case 13:hexStr.at(i)='D';break;??case 14:hexStr.at(i)='E';break;??case 15:hexStr.at(i)='F';break;??default:cout<<"666"<<endl;break;???hexStr.at(i)=Value+'0';//數(shù)字表示的要將數(shù)字轉(zhuǎn)化為對(duì)應(yīng)的字符??}?}?hexStr=hexStr.substr(0,i);//取柚子負(fù)的字串?reverse(hexStr.begin(),hexStr.end());//使用迭代器反轉(zhuǎn)字符串,因?yàn)閷懭氲母叩臀活嵉??return hexStr;//返回對(duì)應(yīng)的16進(jìn)制字符串}string deciToOct(unsigned deci)//十進(jìn)制轉(zhuǎn)八進(jìn)制函數(shù),結(jié)構(gòu)類似于上{?string hexStr(limit,' ');?int Value=0;?int i=0;?if (deci<8)??return string(1,(char)deci);?for (;deci!=0;++i,deci/=8)?{??Value =deci%8;??hexStr.at(i)=Value +'0';?}?hexStr=hexStr.substr(0,i);?reverse(hexStr.begin(),hexStr.end());?return hexStr;}string deciToBin(unsigned deci)//十進(jìn)制轉(zhuǎn)二進(jìn)制函數(shù),結(jié)構(gòu)類似于上{ ??? string hexStr(3*limit,' ');int Value =0;int i =0;for(;deci!=0;++i,deci/=2){?Value =deci%2;?hexStr.at(i)=Value+'0';}hexStr=hexStr.substr(0,i);reverse(hexStr.begin(),hexStr.end());return hexStr;}long anyToDeci(const string any,const unsigned scale){?long sum=0;//sum為累加和?int n=any.length();//使用string類的方法獲得字符串的長(zhǎng)度?for (int i=0;i<n;i++)??if(any.at(i)>'0'&&any.at(i)<='9')???sum+=(any.at(i)-'0'*pow(scale,n-1-i);//按權(quán)展開(kāi)的冪乘和累加??sum+=(any.at(i)-'a'+*pow(scale,n-1-i);??else???sum+=(any.at(i)-'A'*pow(scale,n-1-i);??return sum;}#endif //CONVERTFUNCS_H_INCLUDED
查看完整描述

2 回答

  • 2 回答
  • 0 關(guān)注
  • 940 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)