问题是: 在一个26名学生的班级中,给出了一个包含10个问题的测试。学生们通过掷硬币来回答问题。我必须找出有多少学生有两个或更少的答案是正确的。这是我编写的程序,但我不确定它...是好的吗?如何计算数量?
correct=0;
students=0;
for i=1:26
for j=1:10
answ=ceil(rand);
if answ==1
correct=correct+1;
if correct==2
students=students+1;
end
end
end
end
disp(students)
它对您有用吗? – chappjc
为了记录,这实际上是一个预定义的函数。 Y ='binocdf(10,26,0.5)'http://www.mathworks.com/help/stats/binocdf.html – PearsonArtPhoto