zoukankan      html  css  js  c++  java
  • 实验7

    #include<iostream>
    using namespace std;
    int main()
    {
        ios_base::fmtflags original_flags = cout.flags();//保存当前格式
        cout << 812 << '|';
        cout.setf(ios_base::left, ios_base::adjustfield);//左对齐
        cout.width(10);                              //设置宽度为10
        cout << 813 << 815 << '
    ';
        cout.unsetf(ios_base::adjustfield);      //设置为默认
        cout.precision(2);
        cout.setf(ios_base::uppercase | ios_base::scientific); //显示16进制大写,以及E|使用科学记数法
        cout << 831.0;
        cout.flags(original_flags);//设置为初始格式设置
        return 0;
    }

    11-3

    #include<iostream>
    #include<fstream>
    using namespace std;
    int main()
    {
        ofstream file;
        file.open("text1.txt");
        file << "已成功写入文件";
        file.close();
        return 0;
    }

    11-4

    #include<iostream>
    #include<string>
    #include<fstream>
    using namespace std;
    int main()
    {
        ifstream file;
        string t;
        file.open("text1.txt");
        getline(file, t);
        cout << t<<endl;
        file.close();
        return 0;
    }

  • 相关阅读:
    另一个博客
    友情链接&部分题目的密码
    知识点汇总
    一些模板的调试样例
    摘抄
    通过代理连接Microsoft Store和更新Windows系统
    模电复习
    Codeforces Round #583 F Employment
    杂感(三)
    杂感(二)
  • 原文地址:https://www.cnblogs.com/miaorui1314/p/9206547.html
Copyright © 2011-2022 走看看