头文件:
#include <iostream>
#include <iomanip>
using namespace std;

功能: 

std::setw :需要填充多少个字符,默认填充的字符为' '空格

std::setfill:设置std::setw将填充什么样的字符,如:std::setfill('*')

示例:

 #include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <iomanip> int _tmain(int argc, _TCHAR* argv[])
{
int a = ;
//输出: 1
std::cout<<std::setw()<<a<<std::endl;
//输出: ***1
std::cout<<std::setw()<<std::setfill('*')<<a<<std::endl; //输出:***12
int b = ;
std::cout<<std::setw()<<std::setfill('*')<<a<<b<<std::endl;
system("pause");
return ;
}

std::setw(size)与std::setfill(char)的更多相关文章

  1. VC++ : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<wchar_t,struct std::char_traits<wchar_t>

    最近学习Google Breakpad,将其用在了自己的项目中,编译的版本为VS2010,没有什么问题.但是为了和之前的程序兼容,需要使用VS2008版本的程序,于是又编译了VS2008版本的代码,但 ...

  2. 你想知道的 std::vector::push_back 和 std::vector::emplace_back

    引言 C++ 11 后,标准库容器 std::vector 包含了成员函数 emplace 和 emplace_back.emplace 在容器指定位置插入元素,emplace_back 在容器末尾添 ...

  3. 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)'

    error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Tra ...

  4. error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler op

    caffe c++11编译问题 问题:error: #error This file requires compiler and library support for the ISO C++ 201 ...

  5. std::array中的std::get<n>()

    模板函数std::get<n>()是一个辅助函数,它能够获取到容器的第 n 个元素.模板参数的实参必须是一个在编译时可以确定的常量表达式,编译时会对它检查. get<n>()模 ...

  6. 使用log4cplus时遇到的链接错误:无法解析的外部符号 "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,

    #include "stdafx.h" #include <log4cplus/logger.h> #include <log4cplus/loggingmacr ...

  7. Error 2 error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)'

    Error 2 error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree ...

  8. 将std::array转换成std::tuple

    template<typename Array, std::size_t... Index> decltype(auto) array2tuple_impl(const Array& ...

  9. mod_tile编译出错 -std=c++11 or -std=gnu++11

    make[1]: 正在进入文件夹 /home/wml/src/mod_tile-master' depbase=echo src/gen_tile.o | sed 's|[^/]*$|.deps/&a ...

随机推荐

  1. 云计算核心组件--keystone身份认证服务(5)

    一.Keystone介绍: keystone 是OpenStack的组件之一,用于为OpenStack家族中的其它组件成员提供统一的认证服务,包括身份验证.令牌的发放和校验.服务列表.用户权限的定义等 ...

  2. python利用smtp发送邮件

    #!/usr/bin/env python # -*- encoding: utf-8 -*- # author:IversOn5 import requests import json import ...

  3. AKKA文档2.1(java版)——什么是AKKA?

    可扩展的实时事务处理 我们相信编写并发.容错.可扩展的应用相当的困难.盖因大多数时候我们一直在使用错误的工具和错误的抽象等级.AKKA就是为了改变这一切的.我们利用角色模型提升了抽象等级,并且提供了一 ...

  4. zip 命令

    NAME zip - package and compress (archive) files SYNOPSIS         zip [-aABcdDeEfFghjklLmoqrRSTuvVwXy ...

  5. CMMI将能力成熟度分为5个级别

    CMMI将能力成熟度分为5个级别(初始级,已管理级,已定义级,量化管理级,优化级) . 初始级 此时软件过程是无序的,有时甚至是混乱的,对过程几乎没有定义,成功取决于个人努力.管理是反应式的. .可管 ...

  6. # Tallest Cows(差分)

    Tallest Cows(差分) n头牛,给出最高牛的位置和身高,其他牛身高未知,给出m对相对关系,表示可以相互看见当且仅当他们中间的牛都比他们矮.求每头牛身高最大值是多少. 差分数组的性质:前缀和为 ...

  7. 2019年8月23日 星期五(韩天峰的swoole)

    Swoole:面向生产环境的 PHP 异步网络通信引擎 使 PHP 开发人员可以编写高性能的异步并发 TCP.UDP.Unix Socket.HTTP,WebSocket 服务. Swoole 可以广 ...

  8. springboot读取配置不存在报错

    @Value("${log.regId}")private String regId = "123123"; String regId = env.getPro ...

  9. Wizard's Tour CodeForces - 860D (图,构造)

    大意: 给定$n$节点$m$条边无向图, 不保证连通, 求选出最多邻接边, 每条边最多选一次. 上界为$\lfloor\frac{m}{2}\rfloor$, $dfs$贪心划分显然可以达到上界. # ...

  10. redis 学习(14)-- HyperLogLog

    HyperLogLog 什么是 HyperLogLog HyperLogLog 是基于 HyperLogLog 算法的一种数据结构,该算法可以在极小空间完成独立数量统计. 在本质上还是字符串类型. 重 ...