4.7.4.c pp
来自「通过从文件中录入学生成绩,对成绩进行分析.并将结果存入文件」· C PP 代码 · 共 76 行
C PP
76 行
#include<iostream>
#include <fstream>
#include"CBaseStudent.h"
using namespace std;
void totalfail(CStudent st4[6])
{ ofstream outfile4("不及格统计4.txt");
for (int i=0;i<6;i++)
{ int j=0;
if(st4[i].Getmaths()<60)
{
j++;
}
if(st4[i].Getenglish()<60)
{
j++;
}
if(st4[i].Getphysics()<60)
{
j++;
}
if(st4[i].Getvc()<60)
{
j++;
}
if(st4[i].Getftenet()<60)
{
j++;
}
if(st4[i].Getsports()<60)
{
j++;
}
if(st4[i].Getpolitics()<60)
{
j++;
}
if(j>0)
{
cout<<"编号:"<<st4[i].Getnum()<<" "<<st4[i].Getname()<<"的英语成绩为:"<<st4[i].Getenglish()<<endl;
cout<<"编号:"<<st4[i].Getnum()<<" "<<st4[i].Getname()<<"的数学成绩为:"<<st4[i].Getmaths()<<endl;
cout<<"编号:"<<st4[i].Getnum()<<" "<<st4[i].Getname()<<"的物理成绩为:"<<st4[i].Getphysics()<<endl;
cout<<"编号:"<<st4[i].Getnum()<<" "<<st4[i].Getname()<<"的vc成绩为:"<<st4[i].Getvc()<<endl;
cout<<"编号:"<<st4[i].Getnum()<<" "<<st4[i].Getname()<<"的政治成绩为:"<<st4[i].Getpolitics()<<endl;
cout<<"编号:"<<st4[i].Getnum()<<" "<<st4[i].Getname()<<"的体育成绩为:"<<st4[i].Getsports()<<endl;
cout<<"编号:"<<st4[i].Getnum()<<" "<<st4[i].Getname()<<"的组成原理成绩为:"<<st4[i].Getftenet()<<endl;
cout<<st4[i].Getname()<<"不及格课程共"<<j<<"门"<<endl;
outfile4<<"编号:"<<st4[i].Getnum()<<" "<<st4[i].Getname()<<"的英语成绩为:"<<st4[i].Getenglish()<<endl;
outfile4<<"编号:"<<st4[i].Getnum()<<" "<<st4[i].Getname()<<"的数学成绩为:"<<st4[i].Getmaths()<<endl;
outfile4<<"编号:"<<st4[i].Getnum()<<" "<<st4[i].Getname()<<"的物理成绩为:"<<st4[i].Getphysics()<<endl;
outfile4<<"编号:"<<st4[i].Getnum()<<" "<<st4[i].Getname()<<"的vc成绩为:"<<st4[i].Getvc()<<endl;
outfile4<<"编号:"<<st4[i].Getnum()<<" "<<st4[i].Getname()<<"的政治成绩为:"<<st4[i].Getpolitics()<<endl;
outfile4<<"编号:"<<st4[i].Getnum()<<" "<<st4[i].Getname()<<"的体育成绩为:"<<st4[i].Getsports()<<endl;
outfile4<<"编号:"<<st4[i].Getnum()<<" "<<st4[i].Getname()<<"的组成原理成绩为:"<<st4[i].Getftenet()<<endl;
outfile4<<st4[i].Getname()<<"不及格课程共"<<j<<"门"<<endl;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?