首页 > > 详细

辅导EEE1008、C programming讲解、辅导C/C++语言、讲解C/C++程序设计 调试Matlab程序|讲解SPSS

Assignment 4 (EEE1008 C programming)
In this assignment you will implement your own simple programming language for matrices.
Problem
Write a program that allows the user to enter commands (one command per line), executes
them, and terminates when requested. The program should support the following commands:
set variable a11 a12 a21 a22 – assign a 2x2 matrix to a variable, for example, the
command set X 1 2 3 4 assigns the following matrix to variable X:
(
1 2
3 4
)
variable = expression – compute an expression and assign the result to a variable. An
expression has the form variable op variable, where op is an operator (+, – or *).
Examples: X = Y + Z, A = A – B.
print variable – print the matrix stored in a variable, see examples below.
det variable – compute and print out the determinant of the matrix stored in a variable.
stop – terminate the program.
You can assume that variable names are uppercase characters of English alphabet A-Z. Matrix
elements should have type double. As always, you do not have to follow exactly the same input
and output format as in the example below. Feel free to experiment by adding more commands
to your language, for example to compute matrix inverse or multiplication by a vector.
Example
Here a user inputs commands (left) and the program prints out results (right) when required.
Input:
set A 1 2 3 4
print A
set B 1 0 0.5 -1
C = A * B
B = C - B
print B
det B
stop
Output:
A = 1.00 2.00
3.00 4.00
B = 1.00 -2.00
4.50 -3.00
det(B) = 6.00
Submission
Submit both the program source and a report describing your solution via Blackboard.
Alternative Assignment 4
Assignment 4 is the last assignment of the C programming module. If you are already confident
in your problem-solving skills, and would like to reflect on what you have learned in the module,
you have an option to create a new C programming assignment instead of solving one. If we like
your assignment, we will use it in teaching future students. See the marking criteria document.
Submission of alternative assignment
Submit a 2-page report: the 1st page is the assignment specification (follow the format used in
Assignments 2-4); the 2nd page describes the author solution of the assignment, 5-6 tests that
can be used by the markers to evaluate a solution, and a rationale for the problem (which topics
of the module it covers). You should also submit the program source of your solution in C.

联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!