Searched the entire network on the topic of explanation and illustration, and test a number of other cases, others reaction of the pit is jumped over, but it is the last test points not, amended their read function, also modified sort function, were not through, hope to have been a problem of students can give some help thank you, or there is something wrong with the given test case, thank you very much!
# include
# include
# include
# define MaxUsers 10001
Typedef struct Stu {
Int id;
Int total;
Int score [5];
Int full;
} the List [MaxUsers];
Int read (int table [], the List stu, int full_score [], int p_num, int m);
Void Shell_Sort (int table [], the List stu, int n);
Int Check (int table [], the List stu, int TMP, int tmpid, int j, int d);
Void Init (List stu, int id, int p_num);
//int the compare (const void * a, const void * b);
Int main ()
{
Int n, k, m, I, j, real_user;
The List stu.
The scanf (" % d % d % d ", & amp; N, & amp; K, & amp; M);
Int full_score [k].//record title out
For (I=0; iThe scanf (" % d ", & amp; Full_score [I]);
Int table [n].//table records need to display the number of users, behind only sort to sort the table can be
For (I=0; iThe table [I]=1;
//start reading data, read back need to display the number of users
Real_user=read (table, stu, full_score, k, m);
//tree (table, real_user, sizeof (int), compare);//to quickly sort table
Shell_Sort (table, stu, real_user);//to hill sort table
//the following sequential output table of user
Int last;
For (I=0; i{
Int TMP=table [I];
If (I==0)
{
Printf (" % d ", I + 1);
The last=I + 1;
}
The else {
If (stu (TMP). The total==stu [table] [I - 1]. Total)
Printf (" % d ", the last);
The else {
Printf (" % d ", I + 1);
The last=I + 1;
}
}
05 printf (" % d % d ", TMP, stu (TMP). The total);
For (j=0; j{
If (stu (TMP). The score [j].=1)
Printf (" % d ", stu (TMP). The score [j]);
The else
Printf (" - ");
}
If (I.=real_user - 1)
printf("\n");
}
return 0;
}
Void Shell_Sort (int table [], the List stu, int n)
{
Int I, j, d, k=0;
Int TMP, tmpno;
While (pow (2 k) - 1 & lt; N)
+ + k;
- k;//use Hibbard incremental sequence
for( ; K>=1; - k)
{
D=pow (2 k) - 1;
For (I=d; i{
TMP=stu [table] [I]. Total;//TMP records the current user's total score
Tmpid=table [I];//tmpid records for the current user id
For (j=I; j>=d & amp; & Check (table, stu, TMP, tmpid, j, d); J -=d)
{
The table [j]=table [j - d];
}
The table [j]=tmpno;
}
}
}
Int Check (int table [], the List stu, int TMP, int tmpid, int j, int d)
{
If (TMP & gt; Stu [table] [j - d] total)//total score is
return 1;
Else if (TMP==stu [table] [j - d]. Total)
{
If (stu [table] [j]. J full & gt; Stu [table] [j - d] full)//out of subjects is
return 1;
Else if (stu [table] [j]. J full==stu [table] [j - d]. Full)
{
If (tmpid & lt; Table [j - d])//id size comparison
return 1;
}
}
return 0;
}
Void Init (List stu, int id, int p_num)//initialize the serial number of the current structure of stu
{
int i;
Stu [id]. Total=0;
Stu [id]. Full=0;
For (I=0; iStu [id]. Score [I]=1;
}
Int read (int table [], the List stu, int full_score [], int p_num, int m)
{
Int id, no score, flag;//CNT is used to record the movement of the table array, used to return to the need to display the number of users
Int I, j, k, CNT=1;//record array to record the current state of the user
Int record [10001].//record [id]==0 that the current user does not have any operation
For (I=0; i<10001; + + I)//record [id]==1 shows that the current user has meet according to ranking
the condition ofRecord [I]=0;//record [id]==2 show the current user had record but failed by
For (I=0; i{
The scanf (" % d % d % d ", & amp; Id, & amp; No, & amp; Score);
If (! Record [id])//if the user has never been compiled
{
Init (stu, id, p_num);//initialize the user structure, in which each scoring record of 1
If (score==1) {//if the compilation fails
Stu [id]. Score/no 1=2;//record the door score was 2 to subsequent processing
Record [id]=2;//change the status to have compiled records but neither by
}
The else {//if the compiler success
Stu [id]. Total=score;//total change
Stu [id]. Score/no 1=score;//the door score value change
If (full_score [] no - 1==score)//if out of the full score plus a
+ + stu [id]. Full;
The table [+ + CNT]=id;//need to display the number of users to add a
Record [id]=1;//change the status to need to display
}
}
Else if (record [id]==1) {//if the user status to have records for the need to display
If (score==1)//if the compilation fails, the score of 0
+ + score;
If (score & gt; Stu [id]. Score [] no - 1)//if the score is greater than the last score
{
If (stu [id]. Score [no 1]==1)//if the problem has never been compiled, directly change the score to 0
Stu [id]. Score [] no - 1=0;
Stu [id]. Total +=(score - stu [id]. Score [] no - 1);//add is equal to the total score to submit score to lose the original score
Stu [id]. Score/no 1=score;//the topic grade change
If (full_score [] no - 1==score)//if out of the full score plus a
+ + stu [id]. Full;
}
}
Else if (record [id]==2) {//if the user status to submit compile but lost
If (score==1)//if the submitted also compile failed
{
Stu [id]. Score/no 1=2;//is the submit on compiling failure tag
}
The else {//if the submitted successful (compile)
For (k=0; KIf (stu [id]. Score [k]==2)
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull