help me!

+1 hoang snow · May 9, 2015
Source Code: q2.cpp, vector.h, vector.cpp
There is a list of vector operators which you must compute. Each vector operator is written with the following format:
<vector> <operator> <vector>  
where a vector is written as [ a1  a2 … an ] (elements are separated together by space), and operator may be *, + or -.
For example:
[ 0 1 3 ] * [ 3 1 0 ]
[ 0 1 3 ] - [ 0 1 3 ]
[ 0 1 3 ] + [ 0 1 3 ]
Please write a programme read vectors operators from vector.inp file. After that, evaluate them and write results into output file vector.out:
Input file: vector.inp
The first line writes an integer N which is the number of vector operators. Subsequently, each line in N following lines contains a vector operator. All attributes of vectors are integers in -1000…1000. It is known that all these operators are valid or computable.
Output file: vector.out
For each vector operator in the input, write its result in a line of this output file.
vector.inp
vector.out
3
[ 0 1 3 ] * [ 3 1 0 ]
[ 0 1 3 ] - [ 0 1 3 ]
[ 0 1 3 ] + [ 0 1 3 ]
 
1
[ 0 0 0 ]
[ 0 2 6 ]
 
Hints:
§  Try to use the new knowledge which have just learned such as friend class or friend function, or/and overloading operators, …

Post a Reply

Replies

Oldest  Newest  Rating
0 Michael Bradford · May 11, 2015
You didn't actually say what specifically you needed help with, if we just DO your homework for you, you wont actually learn anything. If there is some specific aspect of this confusing you please let us know we'll try to help. 
0 Neal Carico · May 13, 2015
Lol literally copied and pasted a question from a homework assignment.. Well. If you give us more we have help you understand it. 
0 Troy Jones · May 13, 2015
The answer is 42
  • 1

C++

107,131 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator