实验七

Posted anxx

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了实验七相关的知识,希望对你有一定的参考价值。

11—7
#include <iostream>
using namespace ::std;
int main() {
ios_base::fmtflags original_flags = cout.flags(); //保存cout参数设置 
cout<< 812<<‘|‘;
cout.setf(ios_base::left,ios_base::adjustfield); //设置cout的对齐方式为左对齐 
cout.width(10); //将cout宽度改为10 
cout<< 813 << 815 << ‘/n‘;
cout.unsetf(ios_base::adjustfield); //取消cout对齐方式的设置 
cout.precision(2);// 设置浮点数输出的精度值 
cout.setf(ios_base::uppercase|ios_base::scientific); //设置浮点数的显示参数 
cout << 831.0 ;
cout.flags(original_flags); //恢复cout原参数设置 
return 0;
}

  

技术分享图片

11—3.

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

 技术分享图片

11—4.

#include<fstream>
#include<iostream>
using namespace std;
int main(){
    char ch;
    ifstream test1("test.txt");
    while(test1.get(ch))
    cout<<ch;
    test1.close();
}

 技术分享图片

 

 总结:

只完成了三个基础练习,这次实验完成的不太好。

 

 

 

以上是关于实验七的主要内容,如果未能解决你的问题,请参考以下文章