1508-张晨曦总结《2016年-11月-26日》【连续36天总结】

标题:新的一天是吧

关键词:标准输出流

内容

A. 一句话概括今日目标完成情况

a)标准输出流的学习 100%

b)无

B.具体内容

 标准输出设备就是显示器

cout是ostream类的一个对象,<<就是流插入运算符

put 无格式插入一个字节

write  无格式插入一字节序列

flush 刷新输出流

seekp 移动输出流指针

tellp  返回输出流中置顶位置的指针值

这是一些常用的函数

然后学习了 setf unsetf width precision fill 这几个 成员函数,然后学习了ios类的一些常用状态标志。

实践了以下内容

#include<iostream>
using namespace std;
int main()
{
    cout.setf(ios::left|ios::showpoint);
    cout.precision(5);
    cout<<123.456789<<endl;
    cout.width(10);
    cout.fill('*');
    cout.unsetf(ios::left);
    cout.setf(ios::right);
    cout<<123.456789<<endl;
    cout.setf(ios::left|ios::fixed);
    cout.precision(3);
    cout<<999.123456<<endl;
    cout<<99.123456<<endl;
    cout.unsetf(ios::left|ios::fixed);
    cout.setf(ios::left|ios::scientific);
    cout<<123.45678<<endl;
    return 0;
}
真特么奇妙

然后是用setiosflags这些函数来控制输出格式

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
    int a=128;
    cout<<"dec: "<<dec<<a<<endl;
    cout<<"hex: "<<hex<<a<<endl;
    cout<<"oct: "<<oct<<a<<endl<<endl;
    char pt[]="Xi'an";
    cout<<setw(10)<<pt<<endl;
    cout<<setfill('*')<<setw(10)<<pt<<endl<<endl;
    double B=27.123456789;
    cout<<setiosflags(ios::scientific)<<setprecision(8);
    cout<<"B= "<<B<<endl;
    cout<<"B= "<<setprecision(4)<<B<<endl;
    cout<<resetiosflags(ios::scientific);
    cout<<"B= "<<setiosflags(ios::fixed)<<setprecision(6)<<B;
    cout<<endl<<"Thanks for using!"<<endl;
    return 0;
}


C.明日计划

 

我的邮箱:smartisandre@yeah.net

我的博客:http://blog.csdn.net/andr3zzzz

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值