Home > Back-end >  Pray god give directions
Pray god give directions

Time:11-14

2. Please help me to design to realize a random program
I am now a total of 50 students, plan to the student named 15 times this term, in order to show my fair, USES the computer random method named student's name, so please come and help me develop a random roll call procedure, requirements are as follows:
1 each randomly selected 10 students' names, and output for their name and student number;
2 can record attendance points to students;
3 to the statistics last each student's attendance points (out of 5 points, not attendance deduction 1 minute at a time, 2 times not attendance 3 points, three attendance 5 points)
4 can you help me to think of other functions

CodePudding user response:

refer to the original poster you camouflage reply:
2. Please help me to design to realize a random program
I am now a total of 50 students, plan to the student named 15 times this term, in order to show my fair, USES the computer random method named student's name, so please come and help me develop a random roll call procedure, requirements are as follows:
1 each randomly selected 10 students' names, and output for their name and student number;
2 can record attendance points to students;
3 to the statistics last each student's attendance points (out of 5 points, not attendance deduction 1 minute at a time, 2 times not attendance 3 points, three attendance 5 points)
4 can you help me to think of other functional

#include
#include
#include
Struct student
{
int id;
Int the name;
Int ml;
Int score;
Int k1.
} s [51];
Int k1 [10].
Void chuanjiang ()
{
for(int i=1; i<=50; I++)
{
S [I]. Id=I;
S [I]. Name=I;
}
}
Int main ()
{
Int d;
Int num [10].
Int CNT=0, n=0;
Void chuanjiang ();
Chuanjiang ();
Srand (clock ());
Int m=0;
For (int l=0; L<15. L++)
{
While (cnt<10)
{
N=rand () % 50 + 1;
for(int i=0; i{
If (num [I]==n)
{
M++;
}
}
If (m==0)
{
Num (CNT)=n;
D=num (CNT);
S [d]. K1=rand () % 2;
If (s [d]. K1==0)
{
S [d]. Ml++;
}
cnt++;
}
M=0;
}
Printf (" \ t \ t % d times to have the first class is point to the student's name and student id: ", l + 1);
for(int i=0; i<10; I++)
{
If (s [num [I]]. K1==1)
{
Printf (" % d \ \ n \ t t s name, student id: % d % d % attendance status: have attendance ", I + 1, num [I], num [I]);
}
If (s [num [I]]. K1==0)
{
Printf (" % d \ \ n \ t t s name, student id: % d % d % attendance status: not attendance ", I + 1, num [I], num [I]);
}
}
printf("\n");
CNT=0;
}
for(int i=1; i<=50; I++)
{
If (s [I]. Ml==0)
{
S [I]. Score=5;
}
If (s [I]. Ml==1)
{
S [I]. Score=4;
}
If (s [I]. Ml==2)
{
S [I]. Score=2;
}
If (s [I] ml>
=3){
S [I]. Score=0;
}
}
For (int g=1; G<=50; G + +)
{
Printf (" \ t \ t % d % d student id students attendance score is % d: \ n ", s [g]. Id, s [g]. Name, s [g] score).
}
system("pause");
return 0;
}

CodePudding user response:

This is the program, the BGF program is all algorithm ah, you don't understand algorithm is how to learn this?

CodePudding user response:

refer to the second floor sinat_38984735 response:
this is the program, the BGF program is all algorithm ah, you don't understand algorithm is how to learn this?

Ah? I this is the program, please write, in fact, I also don't know much about
  • Related