fork download
  1. n=10;
  2. x= rand(n,1)*2-1;
  3. ld=0;
  4. lu=0;
  5. for i=1:n
  6. disp (x(i))
  7. if x(i)>0
  8. disp('wartość jest wartośćią dodatnią')
  9. ld=ld+1;
  10. elseif x(i)<0
  11. disp('wartość jest wartością ujemną')
  12. lu= lu+1;
  13. end
  14. endfor
  15. disp(['Liczba dodatnich:', num2str(ld)])
  16. disp(['Liczba ujemnych:', num2str(lu)])
Success #stdin #stdout 0.07s 46048KB
stdin
Standard input is empty
stdout
 0.49982
wartość jest wartośćią dodatnią
 0.72921
wartość jest wartośćią dodatnią
 0.68510
wartość jest wartośćią dodatnią
 0.049359
wartość jest wartośćią dodatnią
 0.46183
wartość jest wartośćią dodatnią
 0.69857
wartość jest wartośćią dodatnią
 0.52013
wartość jest wartośćią dodatnią
-0.16285
wartość jest wartością ujemną
 0.34982
wartość jest wartośćią dodatnią
-0.99988
wartość jest wartością ujemną
Liczba dodatnich:8
Liczba ujemnych:2