zoukankan      html  css  js  c++  java
  • C++入门经典-例2.11-流输出小数控制

    1:代码如下:

    // 2.11.cpp : 定义控制台应用程序的入口点。
    //
    
    #include "stdafx.h"
    #include <iostream>
    using namespace std;
    void main()
    {
        float x=20,y=-400.00;
        cout << x <<' '<< y << endl;//输出x,空格,y
        cout.setf(ios::showpoint);    //强制显示小数点和无效0
        cout << x <<' '<< y << endl;
        cout.unsetf(ios::showpoint);
        cout.setf(ios::scientific);    //设置按科学表示法输出
        cout << x <<' '<< y << endl;
        cout.setf(ios::fixed);        //设置按定点表示法输出
        cout << x <<' '<< y << endl;
    }
    View Code

    运行结果:

  • 相关阅读:
    poj 3744 题解
    hdu 1850 题解
    New World
    CSP2019游记
    LOJ6052 DIV
    CF809E Surprise me!
    Luogu4548 歌唱王国
    Luogu4581 想法
    Note 5.26-5.28
    LOJ6519 魔力环
  • 原文地址:https://www.cnblogs.com/lovemi93/p/7505547.html
Copyright © 2011-2022 走看看