Advertisement
Guest User

rezolvare

a guest
Dec 11th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. n=2;
  2. Rz=0;
  3. Ry=0;
  4. Rx=0;
  5. for i = 1:n
  6. x=input('x=');
  7. y=input('y=');
  8. z=input('z=');
  9. if x>=0
  10. Fx=x;
  11. else
  12. while x<0
  13. disp('Introduceti o valoare mai mare ca 0!')
  14. x=input('x=');
  15. end
  16. Fx=x;
  17. end
  18. if y>=0
  19. Fy=y;
  20. else
  21. while y<0
  22. disp('Introduceti o valoare mai mare ca 0!')
  23. y=input('y=');
  24. end
  25. Fy=y;
  26. end
  27. if z>=0
  28. Fz=z;
  29. else
  30. while z<0
  31. disp('Introduceti o valoare mai mare ca 0!')
  32. z=input('z=');
  33. end
  34. Fz=z;
  35. end
  36. Rx=Rx+Fx;
  37. Ry=Ry+Fy;
  38. Rz=Rz+Fz;
  39. end
  40. sumR=Rx*Rx+Ry*Ry+Rz*Rz;
  41. R=sqrt(sumR);
  42. disp(R);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement