复制程式
#include <iostream>
#include <stdlib.h>
#include <math.h>
using namespace std;
class student
{
private:
int math,Eng,windows,windows1;
float math1,Eng1;
public:
void student::score();
void student::PrintTitle();
void student::Print();
void student::input();
};
void student::input()
{
printf("math分数:");
cin>>math;
printf("Eng分数:");
cin>>Eng;
printf("windows分数:");
cin>>windows;
}
void student::score()
{
float x;
x=math;
math1=sqrt(x)*10;
if (math1>100){math1=100;}
Eng1=((float)Eng-50)*4/5+60;
windows1=windows+20;
if (windows1>100){windows1=100;}
}
void student::PrintTitle()
{
printf("\n\n%s%12s%9s%10s\n","科目","math","Eng","windows");
for (int k=0;k<(16+9+10);k++) printf("=");
printf("\n");
}
void student::Print()
{
printf("线性调分前 ");
printf("%4d %8d %9d\n",math,Eng,windows);
printf("线性调分后 ");
printf("%3.1f %8.1f %9d\n",math1,Eng1,windows1);
}
int main(int argc, char *argv[])
{
student John;
student Mary;
student Peter;
cout<<"输入John的成绩\n";
John.input();
cout<<"输入Mary的成绩\n";
Mary.input();
cout<<"输入Peter的成绩\n";
Peter.input();
John.score();
Mary.score();
Peter.score();
John.PrintTitle();
cout<<"John的成绩\n";
John.Print();
cout<<"Mary的成绩\n";
Mary.Print();
cout<<"Peter的成绩\n";
Peter.Print();
printf("\n");
system("PAUSE");
return 0;
}