主观

#include ﹤iostream﹥

#include ﹤strinh﹥

#include ﹤iomanip﹥

using namespace std;

class student

{

char name[ 8];

int deg;

char level[7];

friend class process; //说明友元类

public:

student( char na[ ],

 int d)

{

strcpy(name,na);

deg=a;

}

};

class process

{

public:

void trans( student &s)

{

int i=s. deg/10;

switch(i)

{

case 9:

strcpy(s. level, "优"); break;

case 8:

stecpy(s. level, "良"); break;

case 7:

strcpy(s. level, "中"); break;

case 6:

strcpy(s. level, "及格");

break;default:

strcpy(s. level, "不及格"); break;

}

}

void show( student &s)

{cout ﹤﹤setw(10)﹤﹤s.name﹤﹤setw(4)﹤﹤s. deg﹤﹤ setw(8)﹤﹤s.level﹤﹤ endl;}

};

void main( )

{student st[ ]={ student("Jack", 78), student ("Lucy",92),student("Lily", 62), student("Tom", 99 )};

process p;

cout﹤﹤"结果:"﹤﹤"姓名"﹤﹤setw(6)﹤﹤"成绩"﹤﹤sew(8)﹤﹤"等级"﹤﹤endl;

for(int i=0; i ﹤4;i++)

{

p. trans(st[i]);

p. show(st[i]);

}

}

参考答案
您可能感兴趣的试题
¥

订单号:

遇到问题请联系在线客服

订单号:

遇到问题请联系在线客服