4.7.2.cpp

来自「通过从文件中录入学生成绩,对成绩进行分析.并将结果存入文件」· C++ 代码 · 共 53 行

CPP
53
字号
//实现功能一(2):找出每门课程成绩不及格的
#include<iostream>
#include <fstream>
#include"CBaseStudent.h"
using namespace std;
//函数的实现
void fail(CStudent st2[6])

{    
    ofstream outfile2("各科不及格2.txt");
	for (int i=0;i<6;i++)
	 {  
		
		 if(st2[i].Getmaths()<60)    
		 {
			 cout<<"编号:"<<st2[i].Getnum()<<" "<<st2[i].Getname()<<"的数学不及格"<<endl;
	         outfile2<<"编号:"<<st2[i].Getnum()<<" "<<st2[i].Getname()<<"的数学不及格"<<endl;
		 }
		     
		 if(st2[i].Getenglish()<60)    
		 {
			 cout<<"编号:"<<st2[i].Getnum()<<" "<<st2[i].Getname()<<"的英语不及格"<<endl;
	         outfile2<<"编号:"<<st2[i].Getnum()<<" "<<st2[i].Getname()<<"的英语不及格"<<endl;
		 }
		 
		 if(st2[i].Getphysics()<60)    
		 {	cout<<"编号:"<<st2[i].Getnum()<<" "<<st2[i].Getname()<<"的物理不及格"<<endl;
            outfile2<<"编号:"<<st2[i].Getnum()<<" "<<st2[i].Getname()<<"的物理不及格"<<endl;
		 }
		 
		 if(st2[i].Getvc()<60)    
		 {	 cout<<"编号:"<<st2[i].Getnum()<<" "<<st2[i].Getname()<<"的vc不及格"<<endl;
             outfile2<<"编号:"<<st2[i].Getnum()<<" "<<st2[i].Getname()<<"的vc不及格"<<endl;
		 }
		 
		 if(st2[i].Getftenet()<60)    
		 {   cout<<"编号:"<<st2[i].Getnum()<<" "<<st2[i].Getname()<<"的组成原理不及格"<<endl;
             outfile2<<"编号:"<<st2[i].Getnum()<<" "<<st2[i].Getname()<<"的vc不及格"<<endl;
		 }

		 if(st2[i].Getsports()<60)    
		 {	 cout<<"编号:"<<st2[i].Getnum()<<" "<<st2[i].Getname()<<"的体育不及格"<<endl;
		     outfile2<<"编号:"<<st2[i].Getnum()<<" "<<st2[i].Getname()<<"的体育不及格"<<endl;
		 }

		 
		 if(st2[i].Getpolitics()<60)    
		 {    cout<<"编号:"<<st2[i].Getnum()<<" "<<st2[i].Getname()<<"的政治不及格"<<endl;
		      outfile2<<"编号:"<<st2[i].Getnum()<<" "<<st2[i].Getname()<<"的政治不及格"<<endl;
		 }
	}
}      

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?