Home > Back-end >  Delphi - algorithm, the optimal score urgent, online, etc.
Delphi - algorithm, the optimal score urgent, online, etc.

Time:09-21

I novice, is working on a software, is a scoring algorithm is stuck, hope everybody can help me to solve,
Data samples:

Requirements: according to the number of rope skipping find out corresponding points in the table above,
In a grade, for example: 2 ~ 4 times to 10 points, 5 ~ 7 times - 20 points, 8 ~ 10 times 30 points and so on,

CodePudding user response:

Establish a rating table, field: grade, number, scoring, ID
A grade 1 0
A grade 2 10
3 a grade 10
4 a grade 10
.
First grade 120, 100,
.
Second grade 1 0
.

In this way, by grade, number, corresponding to the table, would have been found to score,

CodePudding user response:

The actual number of filter the data set is greater than the number in the table, arranged in reverse chronological order, take the first,

CodePudding user response:

reference 1st floor lyhoo163 response:
create a rating tables, fields, grade, number, scoring, ID
A grade 1 0
A grade 2 10
3 a grade 10
4 a grade 10
.
First grade 120, 100,
.
Second grade 1 0
.

In this way, by grade, number, corresponding to the table, would have been found to score,

Very thank you for your reply,
This case, I have considered the need to score for each of the students; I am looking for a more agile approach, it is best to unified score, such as the whole grade of female
With only a Update statement to complete the raw rope skipping, grading operation, the idea will work more than me?

CodePudding user response:

To build a scale according to the first floor, and then write an update statement update user table set score=(select score table where the from rating=user table. The number and grade=user table. Grade) could be a will be completed all grade a, grade updates

CodePudding user response:

Table 1, rating and fields: grade, classification, coefficient, scoring, ID (coefficient=distance, frequency, time, height)

2, the elaboration to the data requirements, coefficient quantization to 0-2000 - (maximum number), so as long as through SQL

3, select * form corresponding table where grade rating=' ' '=' jump rope and classification of fifth grade 'and coefficient=' 120 ', '
Can get score,

4, through the cycle performance tables, fields, grade, class, name, category, coefficient, scoring, ID (coefficient=distance, frequency, time, height)
While Not the Table. The Eof do
The begin
//select,,,

//Undata,,,
next;
end;

Already very clear, detailed yourself,

CodePudding user response:

Look-up table method:

Const
MIN_CLASS=1;
MAX_CLASS=6;
MIN_FREQ=1;
MAX_FREQ=166;
Var
.. MAX_CLASS ScoreLookupTable=array (1, 1). The MAX_FREQ] of byte=
((0, 0, 10, 10, 10,... ), (... ), (... ), (... ), (... ), (... ));

The function GetScore (Class, Frequency: integer) : integer;
The begin
If a Class & lt; MIN_CLASS then Class:=MIN_CLASS;
If a Class & gt; MAX_CLASS then Class:=MAX_CLASS;
If the Frequency & lt; MIN_FREQ then Frequency:=MIN_FREQ;
If the Frequency & gt; MAX_FREQ then Frequency:=MAX_FREQ;
Result:=ScoreLookupTable [Class] [Frequency];
end;
Lookup table can be hard coded into the program, can also be written to a file, or database (using binary or BLOB types of a database), read before using ScoreLookupTable,

CodePudding user response:

If it is to write their own software, can use the query of the program memory is more flexible