Professional Documents
Culture Documents
Ex 6
Ex 6
Ex 6
const
MAX_GROUPS = 10;
MAX_STUDENTS = 50;
type
ScoreArray = array[1..MAX_STUDENTS] of real ;
var
n, m, i, j: integer;
ScoresMoy: array[1..MAX_GROUPS] of ScoreArray ;
BestScores: array[1..MAX_GROUPS] of real ;
Averages: array[1..MAX_GROUPS] of real ;
Tab_M: array[1..MAX_GROUPS] of Integer ;
scoresTD:array[1..MAX_GROUPS] of ScoreArray;
scoresEX:array[1..MAX_GROUPS] of ScoreArray;
begin
// Read n and m
writeln('Enter the number of groups:');
readln(n);
// Read the number of students for each group and initialize Tab_M vector
writeln('Enter the number of students in each group:');
for i := 1 to n do
begin
writeln('groupe ',i,':');
readln(Tab_M[i]);
end;
// Read the scores for each group and calculate the best score and average
for i := 1 to n do
begin
writeln('Group ', i, ':');
BestScores[i] := 0;
Averages[i] := 0;
for j := 1 to Tab_M[i] do
begin
writeln('Enter score for student ', j, ': ');
write('enter note TP: ');
read(ScoresTD[i][j]);
write('entre note exam: ');
read (scoresEX[i][j]);
scoresMoy[i][j]:=(scoresTD[i][j]*(2/5))+(scoresEX[i][j]*(3/5));
if ((scoresTD[i][j]>=0) and (scoresTD[i][j]<=20)) and ((scoresEX[i][j]>=0)
and (scoresEX[i][j]<=20)) then
writeln('The moyen is:',scoresMoy[i][j]:12:2)
else writeln ('error');
begin
// Update best score for this group
if ScoresMoy[i][j] > BestScores[i] then
begin
BestScores[i] := ScoresMoy[i][j];
end;
end;
end;
// Display best score and average for each group
if ((scoresTD[i][j]>=0) and (scoresTD[i][j]<=20)) and ((scoresEX[i][j]>=0)
and (scoresEX[i][j]<=20)) then
begin
writeln('Group Best Score Average Score');
for i := 1 to n do
writeln(i:5, BestScores[i]:12:2, Averages[i]:16:2)
end;
end.