实验7

#include
#include
#include
#include
#include
#include
using namespace std;
class stu{
	private:
		int order;
		string id,name,cla;
	public:
		stu(const stu &p);
		stu(int orderx,string idx,string namex,string clax);
		void print();
		int geto(){return order;}
		string geti(){return id;}
		string getn(){return name;}
		string getc(){return cla;}
};
stu::stu(const stu &p){
	order=p.order;
	id=p.id;
	name=p.name;
	cla=p.cla;
}
stu::stu(int orderx,string idx,string namex,string clax):order(orderx),id(idx),name(namex),cla(clax){}
void stu::print(){
	cout< stus;
	int order;
	string id,name,cla;
	char ch;//读取上一行的换行符 
	string filename;
	cout<<"输入要打开的班级"<>filename; 
	ifstream fin(filename);
	if(!fin){
		cout<<"fail to open list.txt"<>order>>id>>name>>cla){
		fin.get(ch);
        stus.push_back(stu(order,id,name,cla)) ;
}
		fin.close();
    time_t t = time(0); 
    char tmp[64]; 
    strftime( tmp, sizeof(tmp), "%Y%m%d%H%M%S.txt",localtime(&t) );
    string filename2=tmp;
	ofstream fout(filename2);
	if(!fout){
		cout<<"fail to open"<>n){
		if(n==1){
	int j=rand()%stus.size();
    
	stu exm(stus[j]);
	exm.print();
	fout< 
 

  实验7_第1张图片实验7_第2张图片

 

#include
#include
#include
using namespace std;
int main(){
	string filename;
	cout<<"输入文件名"<>filename;
	ifstream fin(filename);
	if(!fin){
		cout<<"fail to open"<='a'&&line[i]<='z'){
				if(flag==true)
				dcs++;
				flag=false; 
		}
		    else
		    flag=true;
	}
		fin.get(ch); 
		hs++; 
		zfs+=line.size(); 
	}
	cout<<"行数: "< 
 

  实验7_第3张图片实验7_第4张图片

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

  

#include
#include
#include
using namespace std;
int main(){
	string s;
	ifstream in("test1.txt");
	if(!in){
		cout<<"fail to open." << endl;
		return 1;
	}
	in>>s;
	cout< 
 

  实验7_第5张图片实验7_第6张图片

 #include 
using namespace ::std;
int main() {
ios_base::fmtflags original_flags = cout.flags(); //保存cout参数设置 
cout<< 812<<'|';
cout.setf(ios_base::left,ios_base::adjustfield); //左对齐值 
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); //以科学格式显示浮点数 显示大写字母E 
cout <<831.0;
cout.flags(original_flags); //恢复cout原参数设置 
return 0;
}

  

你可能感兴趣的:(实验7)