zoukankan      html  css  js  c++  java
  • 用流控制成员函数输出数据

     1 #include <iostream>
     2 
     3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
     4 using namespace std;
     5 int main(int argc, char** argv) {
     6     int a=21;
     7     cout.setf(ios::showbase);
     8     cout<<"dec:"<<a<<endl;
     9     cout.unsetf(ios::dec);
    10     cout.setf(ios::hex);
    11     cout<<"hex:"<<a<<endl;
    12     cout.unsetf(ios::hex);
    13     cout.setf(ios::oct);
    14     cout<<"oct:"<<a<<endl;
    15     cout.unsetf(ios::oct);
    16     char *pt="China";
    17     cout.width(10);
    18     cout<<pt<<endl;
    19     cout.width(10);
    20     cout.fill('*');
    21     cout<<pt<<endl;
    22     double pi=22.0/7.0;
    23     cout.setf(ios::scientific);
    24     cout<<"pi=";
    25     cout.width(14);
    26     cout.width(14);
    27     cout<<pi<<endl;
    28     cout.unsetf(ios::scientific);
    29     cout.setf(ios::fixed);
    30     cout.width(12);
    31     cout.setf(ios::showpos);
    32     cout.setf(ios::internal);
    33     cout.precision(6);
    34     cout<<pi<<endl;
    35     return 0;
    36 }
  • 相关阅读:
    关于递归的理解
    every few days
    相见恨晚
    VC中自定义消息处理函数的步骤
    wparam和lparam的区别
    VC中新建的类不见了的解决方法
    接连遇到大牛
    老总NB的 romman.sys
    [恢]hdu 1159
    [恢]hdu 1996
  • 原文地址:https://www.cnblogs.com/borter/p/9405524.html
Copyright © 2011-2022 走看看