close
(中譯by sa072686)
Making the Grade

做分數

Mr. Chips has a simple grading scheme that lends itself to automated
computation. You will write a program that will read in his students' grades,
bonus points, and attendance record, compute the student's grades, and output
the average grade point of the class.

Chips 先生有一個簡單的成績表,希望能自動處理分數。你將要寫個程式,

讀入他班上學生的成績、加分以及出缺席記錄,然後決定這個學生的
成績,

並輸出這個班的平均成績。

Mr. Chips grades as follows. All tests are based on 100 points and all test
grades are between 0 and 100 points. If he has given more than 2 tests then
he will drop the lowest test grade for each student before computing student
averages. After computing student averages he computes the overall class
average (mean) and standard deviation (sd). The cutoff points for grades are:
an average tex2html_wrap_inline53 one sd above the mean is an A, an average
tex2html_wrap_inline53 the mean but < one sd above the mean is a B, an
average tex2html_wrap_inline53 one sd below the mean but < the mean is a C,
and an average < one sd below the mean is a D.

Chips 先生是這麼計分的:所有的考試滿分為 100,且分數均介於 0 到 100 分之間。

如果他給了超過兩次考試,則他會在計算學生平均分數之前,將最低的一次考試分數

給捨棄掉。在計算完每個學生的平均分數後,他會計算班級平均分數(mean)

以及標準差(sd)。分段標準如下:如果平均大於等於班平均加標準差

(average >= mean + sd)則得到 A。如果平均小於班平均加標準差,但大於等於班平均

(mean <= average < mean + sd)則得到 B。如果平均小於班平均,但大於等於

班平均減標準差(mean - sd <= average < mean)則得到 C。如果平均小於班平均

減標準差(average < mean - sd)則得到 D。

For every two bonus points accrued by a student Mr. Chips increases their
computed average by 3 percentage points. Thus, if students have one bonus
point, their averages are not bumped at all. If they have 4 or 5 bonus
points, their averages are bumped by 6 percentage points, and so on. Bumping
of averages based on bonus points takes place after the grade cutoff points
have been determined.

每兩個加分點數可以增加三分的平均分數。因此,如果一個學生擁有一個加分點數,

則他的平均分數並不會有任何改變。若他們擁有四或五個,則平均分數可以增加六分,

依此類推。加分點數的計算應在計算分段標準之後。

Finally, for every 4 absences, students lose one letter grade (from A to B, B
to C, C to D, and D to F). For example, if they have 9 absences they will
lose two letter grades. Students cannot get a grade lower than F. If students
have perfect attendance, they gain one letter grade; although they cannot get
a grade higher than an A. During his computations, Mr. Chips always rounds
his results to the nearest tenth. In summary, Mr. Chips drops a student's
lowest test grade if more than 2 tests have been administered, computes each
student's average, computes the class mean and sd, adjusts the students'
averages based on bonus points, determines the student's unadjusted grades,
and then adjusts the grades based on attendance.

最後,每四次缺席將會扣去一個等級(從 A 到 B,從 B 到 C,從 C 到 D,或是

從 D 到 F)。舉例,如果他們擁有九次缺席記錄,則將會被扣去兩個等級。

學生的等級不會低於 F。如果他們擁有完美的出席記錄,則可以增加一個等級,

雖然他們不能夠得到比 A 更高的等級。**(這行看不太懂,我是無條件捨去AC的…)**

總而言之,Chips 先生在有兩次以上考試時,會先將每個學生最低的成績捨棄掉,

然後計算每個學生的平均分數,再計算班平均及標準差,再依照加分點數調整學生的

平均分數,再決定每個學生未調整前的等級,最後依出缺席記錄調整等級。

The average grade point (avg grd pnt) of a class is determined by using 4
points for each A, 3 points for each B, 2 points for each C, 1 point for each
D, and 0 points for each F. The total points for the class are added together
and divided by the number of students in the class (which is always at least
2).

一個班的平均成績(avg grd pnt)依照以下方式計算:每個 A 四分,每個 B 三分,

每個 C 兩分,每個 D 一分以及每個 F 零分,然後把每個班的所有人的分數加起來,

然後除以學生數目(至少兩個)。

The standard deviation sd of a list of numbers tex2html_wrap_inline65 is:

標準差的計算方式如下:

sd = sqrt(sum((average[i]-mean)^2)/n)

If the calculated standard deviation is less than 1 then Mr. Chips uses 1 in
place of the standard deviation for grade calculation.

如果標準差小於 1,則使用 1 代替標準差作為計算成績之用。

Suppose Mr. Chips has 5 students and has given 3 tests. The following table
shows the grades, number of bonuses and days absent, plus the computed
average (with lowest test dropped), the adjusted average (with bonus), the
unadjusted grade and the adjusted grade (with attendance). The mean and sd
used to determine letter grade cutoffs are 69.0 and 20.1. For example, for an
unadjusted B, one's average must be greater than or equal to 69.0 and less
than 89.1.The avg grd pnt is 2.2

假設 Chips 先生有五個學生,並且給了三次考試。則以下的表格將列出分數、加分點數

以及缺席的日子,計算後的平均(已捨去分數最低的一次),算出用加分點數調整後之

平均分數,再計算未調整過的等級以及利用出缺席記錄調整後之等級。用來決定

分段標準之班平均及標準差分別為 69.0 及 20.1。舉個例,未調整後的 B 分數必須

大於等於 69.0 且小於 89.1。班平均成績(avg grd pnt)為 2.2。

Input

輸入

The first line contains an integer N between 1 and 10 describing how many of
Mr. Chip's classes are represented in the input. The first line for each
class contains two integers S and T. S is the number of students in the class
(1 < S < 31) and T is the number of tests the students took (1 < T < 11). The
next S lines will each represent one student in the class. A student line
first lists each of their T test scores as integers between 0 and 100
inclusive, and then lists their bonus points and their number of absences.

第一行包含一範圍在 1 至 10 的整數 N,表示 Chips 先生有幾個班。每個班的第一行

會有兩個整數 S 及 T。S 是學生數,T 是考試數。接下來的 S 行每行代表一個學生。

每行前 T 個數字為該學生 T 次考試的分數,為 0 至 100 間(含頭尾)的整數。

接著是他們的加分點數以及他們缺席次數。

Output

輸出

There should be N+2 lines of output. The first line of output should read
MAKING THE GRADE OUTPUT. There will then be one line of output for each of
Mr. Chip's classes showing that class's average grade point. The final line
of output should read END OF OUTPUT.

必須有 N+2 行輸出。第一行為 MAKING THE GRADE OUTPUT,接著每個班輸出一行

包含該班級的平均成績。最後一行必須為 END OF OUTPUT。


分析一下這題的難度

首先,這題因為題目很長
所以判讀不易。

解釋一下題義
1.輸入的第一行,代表有多少筆測資
2.接下來每組測資的第一行,第一個數字代表有多少學生S,
 第二個數字為總共考試的次數T
3.接下來S行,每一行前T個數字是每個學生T次的考試成績,
 後兩個數字分別是加分點與缺席次數
4.要先算出每個學生的平均分數,但是如果T>2,那麼就要扣除一次最低的分數
 這種情況下,平均用(T-1)次來算
5.把每個學生的平均分數相加再除以人數,就是每個班的班平均(mean)
 而班內的標準差(sd)公式為sd = sqrt(sum((average[i]-mean)^2)
/S)
6.計算完班平均與標準差後,學生的平均與班平均、標準差的關係如下:
  平均分數range                          等第
  average>=mean+sd                 A
  mean+sd>average>=mean    B
  mean>average>=mean-sd     C
  mean-sd>average                    D
7.等第標準算出來之後,要先處理每個學生的加分點
 每有兩個加分點,平均分數可以加三分。
 但這個加分不影響先前所算的mean與sd
8.加分點算上去後,可以計算等第。等第計算完之後,要再處理缺席次數
 每有四次缺席次數,等第就降一等(A->B,B->C,C->D,D->F,沒有E)
 而如果該學生的缺席次數為零次,等第可往上升一等,但最高仍是A等。
9.計算完一個學生真正的等第之後,就要換算一個班的avg grd pnt(平均分數點)
 A=4,B=3,C=2,D=1,F=0
 所有學生的分數點加起來的總和即為此題所須輸出的答案。

如果讓初學者來做這題,
基本上有幾個可能的問題
1.型態轉換的問題
   因為其中有不少牽扯到浮點數與整數的運算,初學者很容易遺忘。
2.忘了要include<math.h>
   sqrt()屬於這個標頭檔。
3.不知道怎麼樣刪掉成績
   我用的方法是邊讀成績邊看哪個成績最小,也邊加總
   如果T>2就把紀錄的最小值減掉,除的時候除以(T-1)
4.需要不少的if判斷式
5.對初學者來說程式碼偏長,我的約85行

總結,對於新手來說,這題要寫對、寫好,除非常寫
否則真正要過,也許要花上一整天

至於已經習慣寫程式的人們
這題也會考驗一點細心以及耐心

大致是這樣′▽`)
arrow
arrow
    全站熱搜

    aikosenoo 發表在 痞客邦 留言(0) 人氣()