201907まとめ

丸め

int(x+0.5)

iostream 小数点位置制御

#include <iostream>
#include <iomanip>
using namespace std;
int main ()
{
    cout<<"10.0/6.0="<<10.0/6<<"无fixed"<<endl;
    cout<<"10.0/6.0="<<10.0/6<<fixed<<setprecision(8)<<"有fixed"<<endl;
    cout<<"10.0/6.0="<<10.0/6<<"无fixed"<<endl;
    cout<<"100.0/6.0="<<100000000.0/6<<fixed<<setprecision(3)<<"有fixed"<<endl;  //此处格式函数无效,输出仍为8位小数
    return 0;
}

fixed<<setprecisionフォーマット機能がない場合、デフォルトで有効数字 6 が出力されます

そこにいる場合fixed<<setprecision、フォーマット機能は、以前の標準に従ってください//無効再定義する変数の前に置か

定数の定義

2種類

const int i=1;
int const i=1;

係数と残り

モジュロとモジュロの違い

数学とプログラミング-剰余、剰余演算とその特性

おすすめ

転載: www.cnblogs.com/FirwoodLin/p/12691297.html