- 积分
- 854
- 鸿鹄币
- 个
- 好评度
- 点
- 精华
- 注册时间
- 2013-1-2
- 最后登录
- 1970-1-1
- 阅读权限
- 40
- 听众
- 收听
中级工程师
|
发表于 2017-6-20 14:41:52
|
显示全部楼层
<<"优秀率:"<<((float)excellent/num)*100<<"%"<<endl
<<"良率:"<<((float)good/num)*100<<"%"<<endl
<<"中率:"<<((float)middle/num)*100<<"%"<<endl;
}
void Sort(Student *a)
{
Student temp;
for(int i=0; i<SIZE-1;i++)
for(int j=0; j<SIZE-i;j++)
{
if(a[j].GetSum()>a[j+1].GetSum())
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
bool SaveData(Student *a)
{
ofstream out;
out.open("Sort.txt",ios::app);
for(int i=0; i<SIZE;i++)
{
out<<a[i].name<<" "<<a[i].number<<" "<<a[i].m_class1<<" "<<a[i].m_class2<<" "<<a[i].m_sum<<endl;
}
out<<endl;
out.close();
return TRUE;
}
bool Load(Student *a)
{
ifstream in;
in.open("myText.txt");
string name;
string number;
int score1;
int score2;
int sum;
if(!in)
{
cout<<"这是新的学生管理系统"<<endl
<<"**********"
<<endl;
return FALSE;
}
else
{
for(int i=0; i<SIZE;i++)
{
in>>name>>number>>score1>>score2>>sum;
a[i].Setmember_Load(name,number,score1,score2,sum);
}
in.close();
return TRUE;
}
}
int main()
{
Student a[SIZE];
int choice;
int flag1=0;
bool flag=Load(a);
Menu();
while(scanf("%d",&choice)==1&&choice!=0)
{
system("cls");
switch(choice)
{
case EXIT:break;
case IN:Input(a);
Show(a);
flag1=1;
break;
case OUT:Analyse(a);
break;
case SORT:Sort(a);
Show(a);
SaveData(a);
break;
case SHOW:Show(a);
break;
}
Menu();
}
ifstream in;
in.open("myText.txt");
if(in)
if(flag1==1)
{
in.close();
in.open("myText.txt",ios_base:ut);
in.close();
for(int i=0; i<SIZE;i++)
a[i].Save();
}
cout<<"欢迎再次使用本系统"<<endl;
return 0;
}
|
659#
2017-6-20 14:41:52
回复(0)
收起回复
|