Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 41 additions & 53 deletions random_roll_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
using namespace std;

struct student {
int number=0;//号码
double grade = 0;//绩点
double pastp = 0;//缺勤系数
double nownumber = 0;//现在缺勤次数
int here[20] = { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }; //到没到
int number=0;//����
double grade = 0;//����
double pastp = 0;//ȱ��ϵ��
double nownumber = 0;//����ȱ�ڴ���
int here[20] = { 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 }; //��û��
}stu[90];
bool cmp(student x, student y)
{
Expand All @@ -19,7 +19,7 @@ bool cmp(student x, student y)
}

double E = 0, numerator = 0, denominator = 0;
string s1 = "软件工程", s2 = "数据库系统原理", s3 = "计算机操作系统", s4 = "计算机图形学", s5 = "大学应用写作";
string s1 = "��������", s2 = "���ݿ�ϵͳԭ��", s3 = "���������ϵͳ", s4 = "�����ͼ��ѧ", s5 = "��ѧӦ��д��";
void read_save1();
void read_save2();
void read_save3();
Expand All @@ -45,72 +45,61 @@ int main()
final_result();
}


int pastp_add(int x, int y)
=======
int pastp_add(int x, int y)
>>
>>>>> main{
if (stu[x].here[y] == 0)//没到
{
if (stu[x].here[y] == 0)//û��
{
stu[x].nownumber++;//现在缺勤次数增加1
stu[x].nownumber++;//����ȱ�ڴ�������1
if (stu[x].nownumber == 1)
{
stu[x].pastp += 0.05; //缺第一次 + 0.05 ,第二次 + 0.5 ,第三次 + 0.5,用以保证偶尔一次缺课不会被一直点名,三次抽取概率增加
stu[x].pastp += 0.05; //ȱ��һ�� + 0.05 ,�ڶ��� + 0.5 ,������ + 0.5�����Ա�֤ż��һ��ȱ�β��ᱻһֱ���������γ�ȡ��������
}
else if (stu[x].nownumber > 1)
{
stu[x].pastp += 0.5;
}
numerator++;
cout<<"缺勤"<<" ";
cout<<"ȱ��"<<" ";
return 1;
}
else
return 0;

}

void address_E(string s)
{
int m,m1,m2;

cout << s << "的抽点方案如下:" << endl;

cout << s << "的抽点方案如下:" << endl;
cout << s << "�ij�㷽������:" << endl;
sort(stu, stu + 90, cmp);

//处理分子
for (int i = 0; i < 20; i++)//对于每一门课的20次课
//��������
for (int i = 0; i < 20; i++)//����ÿһ�ſε�20�ο�
{
sort(stu, stu + 90, cmp);
cout <<"第"<< i+1 << "次课抽点的同学号码为:" ;
for (int j = 0; j < 6; j++)//6个
cout <<"��"<< i+1 << "�ογ���ͬѧ����Ϊ��" ;
for (int j = 0; j < 5; j++)//7��
{
cout << stu[j].number<<" " ;
if (stu[j].here[i] == 0)//没到
if (stu[j].here[i] == 0)//û��
{
numerator++;
cout<<"缺勤"<<" ";
cout<<"ȱ��"<<" ";
stu[j].pastp += 0.5;
}
else
cout<<"出勤"<<" ";
cout<<"����"<<" ";
}
int temp = rand() % 4;//0-3个人
if (temp == 3)//点了3个人
int temp = rand() % 4;//0-3����
if (temp == 2)//����2����
{
int num = (rand() % (7 - 5) + 6);//在除了前几个人里的排名前二抽一个
int num = (rand() % (7 - 5) + 6);//�ڳ���ǰ�������������ǰ����һ��
cout << stu[num].number << " ";
m=pastp_add(num, i);
if(m==0)
cout<<"出勤"<<" ";
cout<<"����"<<" ";
denominator += 1;
}

else if (temp == 3)//点了3个人
else if (temp == 3)//����3����
{
int num1 = (rand() % (9 - 5) + 6);//在除了前几个人里的排名前4抽两个
int num1 = (rand() % (9 - 5) + 6);//�ڳ���ǰ�������������ǰ4������
int num2 = (rand() % (9 - 5) + 6);
while (num2 == num1)
{
Expand All @@ -120,25 +109,24 @@ void address_E(string s)
cout << stu[num1].number<<" " ;
m1=pastp_add(num1, i);
if(m1==0)
cout<<"出勤"<<" ";
cout<<"����"<<" ";
cout << stu[num2].number<<" " ;
m2=pastp_add(num2, i);
if(m2==0)
cout<<"出勤"<<" ";
cout<<"����"<<" ";
denominator += 2;
}

cout << endl;
}
//处理分母
denominator += 120;//前5-8个取了6个
cout << endl;
//������ĸ
denominator += 100;//ǰ5-8��ȡ��5��
cout << endl;
}

void read_save1() //输入第一门课的所有数据
void read_save1() //�����һ�ſε���������
{
ifstream infile;
infile.open("output1.txt"); //注意文件的路径
infile.open("output1.txt"); //ע���ļ���·��
for (int i = 0; i < 90; i++)
{
infile >> stu[i].number;
Expand All @@ -152,10 +140,10 @@ void read_save1() //输入第一门课的所有数据
infile.close();
}

void read_save2() //输入第二门课的所有数据
void read_save2() //����ڶ��ſε���������
{
ifstream infile;
infile.open("output2.txt"); //注意文件的路径
infile.open("output2.txt"); //ע���ļ���·��
for (int i = 0; i < 90; i++)
{
infile >> stu[i].number;
Expand All @@ -169,10 +157,10 @@ void read_save2() //输入第二门课的所有数据
infile.close();
}

void read_save3()//输入第三门课的所有数据
void read_save3()//��������ſε���������
{
ifstream infile;
infile.open("output3.txt"); //注意文件的路径
infile.open("output3.txt"); //ע���ļ���·��
for (int i = 0; i < 90; i++)
{
infile >> stu[i].number;
Expand All @@ -185,10 +173,10 @@ void read_save3()//输入第三门课的所有数据
}
infile.close();
}
void read_save4()//输入第四门课的所有数据
void read_save4()//��������ſε���������
{
ifstream infile;
infile.open("output4.txt"); //注意文件的路径
infile.open("output4.txt"); //ע���ļ���·��
for (int i = 0; i < 90; i++)
{
infile >> stu[i].number;
Expand All @@ -202,10 +190,10 @@ void read_save4()//输入第四门课的所有数据
infile.close();
}

void read_save5()//输入第五门课的所有数据
void read_save5()//��������ſε���������
{
ifstream infile;
infile.open("output5.txt"); //注意文件的路径
infile.open("output5.txt"); //ע���ļ���·��
for (int i = 0; i < 90; i++)
{
infile >> stu[i].number;
Expand All @@ -222,5 +210,5 @@ void read_save5()//输入第五门课的所有数据
void final_result()
{
E = numerator / denominator;
cout << E << endl;
cout << "E��ֵ�ǣ�" << E << endl;
}