我正在尝试为一个程序编写伪代码,该程序可以计算分配的模式中位数和未排序数字的模式,我知道如何获取均值,但是对于模式和中位数,我完全迷失了,我将其放在了下面随时为您提供帮助
老实说,我不知道如何尝试模式和中位数,因为我不知道伪代码如何工作,就像选择最常用的数字一样简单,但我不知道会有什么帮助
Start;
Initialise counter and sum to 0;
Do while there are more numbers;
Get the next number;
Add the number to sum;
Increment the counter;
Loop
Mean = sum/counter;
Display Mean;
End;
如果有人可以将我指向正确的方向,将不胜感激
input nof
counter = 0
sum = 0
if(nof%2==0) then
medpositioneven1=(nof/2)
medpositioneven2=(nof/2)+1
else
medposition = (nof+1)/2
do
input num
sum = sum+num
counter++
if (counter==medposition)
print num
if (counter==medposition1)
firstnum= num
if (counter==medposition2)
secondnum= num
medeven= (firstnum+secondnum)/2
printmedeven
while counter<>nof
end while
mean= sum/nof
print mean
stop