实验7
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(); }
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); }