cout的输出格式初探2
来源:互联网 发布:华为p9上不了移动数据 编辑:程序博客网 时间:2024/05/17 15:58
#include <iostream>#include <iomanip>using namespace std;int main(){cout<<"Chapter 1"<<endl;cout<<" ";cout.setf(ios::left); //设置对齐方式为leftcout.width(7); //设置宽度为7,不足用空格填充cout<<"1.1";cout<<"What's C language";cout.unsetf(ios::left); //取消对齐方式,用缺省right方式cout.fill('.'); //设置填充方式cout.width(30); //设置宽度,只对下条输出有用cout<<1<<endl;cout<<" ";cout.width(7); //设置宽度cout.setf(ios::left); //设置对齐方式为leftcout.fill(' '); //设置填充,缺省为空格cout<<"1.11";cout<<"The history of C";cout.unsetf(ios::left); //取消对齐方式cout.fill('.');cout.width(30);cout<<58<<endl;cout.fill(' ');cout<<"Chapter 2"<<endl;cout<<"----------------------"<<endl;cout<<"Chapter 1"<<endl;cout<<" ";cout<<setiosflags(ios::left)<<setw(7); //设置宽度为7,left对齐方式cout<<"1.1";cout<<"What's C language";cout<<resetiosflags(ios::left); //取消对齐方式cout<<setfill('.')<<setw(30)<<1<<endl; //宽度为30,填充为'.'输出cout<<setfill(' '); //恢复填充为空格cout<<" ";cout<<setw(7)<<setiosflags(ios::left); //设置宽度为7,left对齐方式cout<<"1.11";cout<<"The history of C";cout<<resetiosflags(ios::left); //取消对齐方式cout<<setfill('.')<<setw(30)<<58<<endl; //宽度为30,填充为'.'输出cout<<setfill(' ')<<"Chapter 2"<<endl;return 0;}
程序运行结果如下图:
0 0
- cout的输出格式初探2
- cout的输出格式初探
- cout的输出格式初探3
- cout的输出格式
- cout的格式输出
- cout格式输出的使用
- cout<<格式输出的使用
- cout输出的格式控制
- cout的输出格式(转)
- cout输出的常用的一些格式
- 如何设置cout的输出格式(转)
- 如何设置cout的输出格式(转)
- cout如何输出数值的二进制格式
- C++的cout语句格式控制输出
- cout格式输出
- cout选择输出格式
- cout格式输出
- c++ cout 格式输出
- IOS延长启动画面的两种方法
- 你的站为什么百度无动于衷——10年老站长的SEO肺腑之言
- Lamada的First and Default and Single
- 史上最全的程序员求职渠道总结
- I2C总线协议详解
- cout的输出格式初探2
- Selenium学习一 页面元素定位
- 使用devstack安装OpenStack时如何指定版本
- scala 基本语法
- Windows查看进程和结束进程的方法
- Dialog样式的Activity
- 《⑨也懂系列:MinGW安装教程Ver.2》著名C/C++编译器GCC的Windows版本
- Eclipse在异常关闭后,启动闪退的解决办法(转)
- php中include文件变量作用域的研究 -- 转自微信