1:代码如下:

// 2.11.cpp : 定义控制台应用程序的入口点。
// #include "stdafx.h"
#include <iostream>
using namespace std;
void main()
{
float x=,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;
}

运行结果:

C++入门经典-例2.11-流输出小数控制的更多相关文章

  1. C++入门经典-例2.10-控制输出精确度

    1:代码如下: // 2.10.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> usin ...

  2. C++入门经典-例2.8-输出整数,控制打印格式

    1:代码如下: // 2.8.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> #incl ...

  3. C++入门经典-例6.12-使用数组地址将二维数组输出

    1:以a[4][3]为例 a代表二维数组的地址,通过指针运算符可以获取数组中的元素 (1)a+n代表第n行的首地址 (2)&a[0][0]既可以看作第0行0列的首地址,同样也可以被看作是二维数 ...

  4. C++入门经典-例3.11-使用if语句来实现根据输入的字符输出字符串

    1:代码如下: // 3.11.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> usin ...

  5. C++入门经典-例3.25-使用循环输出闰年

    1:代码如下: // 3.25.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> usin ...

  6. C++入门经典-例3.23-使用嵌套循环输出乘法口诀表

    1:代码如下: // 3.23.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iomanip> #incl ...

  7. C++入门经典-例3.12-使用if-else语句实现根据输入的字符输出字符串

    1:代码如下: // 3.12.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> usin ...

  8. C++入门经典-例3.10-根据输入的字符输出字符串

    1:代码如下: // 3.10.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> #inc ...

  9. C++入门经典-例2.6-简单用cout输出字符

    1:代码如下: // 2.6.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> using ...

随机推荐

  1. The Party and Sweets CodeForces - 1159C (拓排)

    优化连边然后拓排. #include <iostream> #include <sstream> #include <algorithm> #include < ...

  2. Leetcode简单题

    # Title Solution Acceptance Difficulty Frequency     1 Two Sum       44.5% Easy     2 Add Two Number ...

  3. VMware中centos7访问外网配置

    1.配置虚拟机网络适配器,选择NAT模式 2.在编辑->虚拟机网络编辑器->更改设置 选择目前使用的网卡 3.通过ifconfig查看网卡配置 4.编辑网络配置对应上面网卡名称ens33 ...

  4. sql--inner join , out join

    inner join(又叫join) out join包括left join,right join和full join(也就是left+right)

  5. Git复习(六)之标签管理

    标签管理 发布一个版本时,我们通常先在版本库中打一个标签(tag),这样,就唯一确定了打标签时刻的版本.将来无论什么时候,取某个标签的版本,就是把那个打标签的时刻的历史版本取出来.所以,标签也是版本库 ...

  6. 订单支付倒计时-剩余时间xx小时xx分xx秒

    //<input type="hidden" id="endTime" value="1554912000000"> 结束时间 ...

  7. git 基本命令操作

    配置 Git 的相关参数. Git 一共有3个配置文件: 1. 仓库级的配置文件:在仓库的 .git/.gitconfig,该配置文件只对所在的仓库有效.2. 全局配置文件:Mac 系统在 ~/.gi ...

  8. leetcode 对角线遍历 JavaScript

    JavaScript /** * @param {number[][]} matrix * @return {number[]} */ var findDiagonalOrder = function ...

  9. Get To Know Linux: The /etc/init.d Directory

    If you use Linux you most likely have heard of the init.d directory. But what exactly does this dire ...

  10. kubernetes如何访问pod服务

    一.通过 Service 访问 Pod: 我们不应该期望 Kubernetes Pod 是健壮的,而是要假设 Pod 中的容器很可能因为各种原因发生故障而死掉.Deployment 等 control ...