4、=(x(i)^2)/9+(y(j)^2)/36; a2=(x(i)^2)/36+y(j)^2; a3=(x(i)-2)^2+(y(j)+1)^2; ifa1<1 ifa2<1 ifa3<9 k=k+1; end end end endendmj=(12^2)*k/zs运行结果:mj=3 7.2150方法二:clearN=100
5、00;n=100;forj=1:n k=0;fori=1:N a=12*rand(1,2)-6; x(i)=a(1,1); y(i)=a(1,2); a1=(x(i)^2)/9+(y(i)^2)/36; a2=(x(i)^2)/36+y(i)^2; a3=(x(i)-2)^2+(y(i)+1)^2; ifa1<1 ifa2<1 ifa3<9 k=k+1; end end endendm(j)=(1