Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- n=2;
- Rz=0;
- Ry=0;
- Rx=0;
- for i = 1:n
- x=input('x=');
- y=input('y=');
- z=input('z=');
- if x>=0
- Fx=x;
- else
- while x<0
- disp('Introduceti o valoare mai mare ca 0!')
- x=input('x=');
- end
- Fx=x;
- end
- if y>=0
- Fy=y;
- else
- while y<0
- disp('Introduceti o valoare mai mare ca 0!')
- y=input('y=');
- end
- Fy=y;
- end
- if z>=0
- Fz=z;
- else
- while z<0
- disp('Introduceti o valoare mai mare ca 0!')
- z=input('z=');
- end
- Fz=z;
- end
- Rx=Rx+Fx;
- Ry=Ry+Fy;
- Rz=Rz+Fz;
- end
- sumR=Rx*Rx+Ry*Ry+Rz*Rz;
- R=sqrt(sumR);
- disp(R);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement