diff --git a/random_roll_call.cpp b/random_roll_call.cpp index 54fb163..dcbe3ad 100644 --- a/random_roll_call.cpp +++ b/random_roll_call.cpp @@ -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) { @@ -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(); @@ -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) { @@ -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; @@ -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; @@ -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; @@ -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; @@ -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; @@ -222,5 +210,5 @@ void read_save5()//输入第五门课的所有数据 void final_result() { E = numerator / denominator; - cout << E << endl; + cout << "Eֵǣ" << E << endl; }