成绩管理系统(原创)

//marks-manage
//zhangsisi_04_14
#include <iostream.h>
#include <stdlib.h>
#include <fstream.h>

enum marks_tag { PERFECT = 1, GOOD, GENERAL, UNMARKS };

bool perfectstate( float, float, float );
bool goodstate( float, float, float );
bool generalstate( float, float, float );
bool badstate( float, float, float );
int getStatement( float, float, float );
void showstatement(int);
int main()
{
 ofstream outFile( "marks.txt");
 if( !outFile ) {
   cerr << "can't init." << endl;
   exit( 1 );
 }
 char name[ 30 ];
 long code;
    float english_mark;
 float maths_mark;
 float computer_mark;
 int statement;
 
    outFile << "name" << ' ' << "code" << ' ' << "english" << ' '
      << "maths" << ' ' << "computer" << ' ' << "statement" << endl;
 cout << " 输入信息: " << endl;
 while ( cin >> name >> code >> english_mark >> maths_mark >> computer_mark )
 {
   statement = getStatement( english_mark, maths_mark, computer_mark );
   outFile << name << ' ' << code << ' ' << english_mark
        << ' ' << maths_mark << ' ' << computer_mark << endl;
   showstatement( statement );
   cout << "continue: " << endl;
 }
 return 0;
}


bool perfectstate( float eng, float math, float comp )
{
  if( eng >= 90 && math >= 90 && comp >= 90 )
   return true;
  return false;
}

bool goodstate( float eng, float math, float comp )
{
  if( eng >= 90 && math >= 90 && comp >= 80 && comp < 90 )
   return true;
  if( eng >= 90 && math >= 80 && math < 90 && comp >= 90 )
   return true;
  if( eng < 90 && eng >= 80 && math >= 90 && comp >= 90 )
   return true;
  return false;
}

bool generalstate( float eng, float math, float comp )
{
  if( eng >= 90 && math >= 80 && math < 90 && comp >= 80 && comp < 90 )
   return true;
  if( eng >=80 && eng < 90 && math >= 90 && comp >= 80 && comp < 90 )
   return true;
  if( eng >= 80 && eng < 90 && math >= 80 && math < 90 && comp >= 90 )
   return true;
  return false;
}

bool badstate( float eng, float math, float comp )
{
bool perfectstate( float, float, float );
bool goodstate( float, float, float );
bool generalstate( float, float, float );
  if( !( perfectstate( eng, math, comp ) ) )
   ;
  else return false;
  if( !( goodstate( eng, math, comp ) ) )
   ;
  else return false;
  if( !( generalstate( eng, math, comp ) ) )
   ;
  else return false;
  return true;

}


int getStatement( float eng, float math, float comp )
{
  bool perfectstate( float, float, float );
  bool goodstate( float, float, float );
  bool generalstate( float, float, float );
  bool badstate( float, float, float );
  int statement; 
  if( perfectstate( eng, math, comp ) )
  statement = 1;
  if( goodstate( eng, math, comp ) )
   statement = 2;
  if( generalstate( eng, math, comp ) )
   statement = 3;
  if( badstate( eng, math, comp ) )
   statement = 4;
  return statement;

}


void showstatement(int st)
{
 ofstream outFile1( "marks.txt", ios::nocreate | ios::ate );
 if( !outFile1 ) {
   cerr << "can't init." << endl;
   exit( 1 );
 } 
 switch (st) {
 case PERFECT:
  outFile1 << "perfect" << endl;
  break;
 case GOOD:
  outFile1 << "good" << endl;
  break;
 case GENERAL:
  outFile1 << "general" << endl;
  break;
 case UNMARKS:
  outFile1 << "unmarks" << endl;
  break;
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值