实验七
11-3
#include<iostream> #include<fstream> using namespace std; int main() { ofstream file("test1.txt"); file<< "已成功写入文件!"; file.close(); return 0; }
11-4
#include<fstream> #include<iostream> using namespace std; int main(){ char ch; ifstream file1("test.txt"); while(file1.get(ch)) cout<<ch; file1.close(); }
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); cout<<813<<815<<'\n'; cout.unsetf(ios_base::adjustfield); cout.precision(2); cout.setf(ios_base::uppercase|ios_base::scientific); cout << 831.0 ; cout.flags(original_flags); }