首页 > 其他 > 详细

实验7

时间:2018-06-20 23:03:09      阅读:157      评论:0      收藏:0      [点我收藏+]
//11-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<<\n;
    cout.unsetf(ios_base::adjustfield);//清除对齐方式的设置 
    cout.precision(2);
    cout.setf(ios_base::uppercase|ios_base::scientific);//科学格式显示大写字母E,更改浮点数的显示设置,以科学格式显示浮点数值 
    cout<<831.0;
    cout.flags(original_flags);
    return 0;
} 

 

技术分享图片

 

#include<iostream>
#include<fstream>
using namespace std;
int main()
{
    ofstream out("test1.txt");
    if(!out)
    {
        cout<<"fail to open"<<endl;
        return 1;
    }
    out<<"已成功写入文件!";
    out.close();
    return 0;
} 

 

 技术分享图片

 

//11-4
#include<iostream> #include<fstream> #include<string> using namespace std; int main() { ifstream outFile("D:\\text1.txt"); string file; if(outFile) { while(getline(outFile,file)) { cout<<file<<endl; } } outFile.close(); return 0; }

 

 技术分享图片

 

实验7

原文:https://www.cnblogs.com/perservence/p/9206510.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!