C++系列学习笔记

C++系列学习笔记_第1张图片

#include 
#include 

using namespace std;
// namespace:命名空间的关键字
// std:系统的关键字


int main()
{
    cout << "输入" << endl
         << "int,char,double" << endl;
    int num = 0;
    char ch = 0;
    double val = 0.0;
    cin >> num >> ch >> val;
    cout << "num = " << num << " ch = " << ch << " val = " << val << endl;
    cout << "***********************" << endl;
    cout << "oct:" << oct << num << endl;
    cout << "hex:" << hex << num << endl;
    cout << "dec:" << dec << num << endl;
    cout << "***********************" << endl;
    cout << setbase(8) << num << " " << setbase(16) << num << " " << setbase(10) << num << " " << endl;
    cout << "***********************" << endl;
    cout << setw(10) << "num =" << num << endl;                 // 右对齐
    cout << left << setw(10) << "num =" << num << endl;         // 左对齐
    cout << setw(10) << setfill('*') << "num =" << num << endl; // 补全
    cout << "***********************" << endl;
    val = 3.14159265358;
    cout << "val = " << val << endl;                             // 默认6位
    cout << setprecision(2) << "val = " << val << endl;          // 2位有效数字
    cout << fixed << setprecision(2) << "val = " << val << endl; // 2位小数

    return 0;
}

你可能感兴趣的:(QT,C++,c++,笔记,linux,职场和发展,c语言)