Class Vector
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
Create the class Vector with three members x, y, z - private integers.
Implement in the class three constructors:
default constructor that sets to 0 the class members.
constructor with parameters, the parameters are the vector coordinates
copy constructor.
Implement the methods:
double length() - return the length of the vector;
void setX(int), void setY(int), void setZ(int) - methods that change the corresponding values of the vector;
int getX(), int getY() int getZ() - methods that return the corresponding coordinates of the vector.
void Out() - print the coordinates of the vector, separated by a space, then print a new line symbol.
Submit the class only.
class Vector // Java { private int x, y, z; Vector(); // default constructor, set to 0 the members of the class Vector(int x, int y, int z); // constructor with parameters, the parameters are the vector coordinates Vector(Vector v); // copy constructor void setX(int x); // change the value of x void setY(int y); // change the value of y void setZ(int z); // change the value of z int getX(); // return the x coordinate int getY(); // return the y coordinate int getZ(); // return the z coordinate public double length(); // return the length of the vector public void Out(); // return the string - vector coordinates space separated }
Submissions 1K
Acceptance rate 25%