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 }
  • 相关阅读:
    [算法] 网络中最小费用最大流
    [题解] 完美数
    [算法] 扫描线及其应用
    等待时间
    键盘操作
    鼠标操作
    元素常用操作
    元素的定位·CSS
    元素的定位·XPATH
    元素的定位
  • 原文地址:https://www.cnblogs.com/borter/p/9405524.html
Copyright © 2011-2022 走看看