首页 > > 详细

辅导asp、asp设计辅导留学生、调试asp、asp讲解、辅导asp编程

Introduction to Programing and Algorithms
Coursework 2 – Spring 2018
Instructions
About coursework 2
• This coursework (on Octave Programing) is worth 20% of your IPA module mark.
• This asignment comprises 3 questions for a total of 50 marks.
Naming the files and submision
• Name the Octave function files as: Mysign.m, Mynumber.m, Mymatrix.m for
questions 1, 2 and 3 respectively of this coursework.
• Copy+Paste all the above .m files into ONE separate text file.
Name the file as: StudentID.docx e.g. 20030711.docx.
• Please submit your coursework together with a separate signed submision shet
electronicaly via Dropbox on Moodle (under heading: Coursework 2 – Programing).
Note that your work wil not be returned so you should kep a copy for reference.
• The deadline for the submision of this coursework assignment is:
Friday, 1
th
May 2018 (by 3 pm).
Information about marking
• Your functions may use recursion or iteration.
• Your functions should include comments (preceded by) where this wil aid reader’s
understanding. However, there is no need to include a coment for every line of code.
• More marks wil be gained for elegant and reasonably eficient solutions than for long
and tedious ones.
Caution
• If you create functions on your own computer it is your responsibility to ensure that
they perform. corectly on the UNC system. You wil lose marks for functions that wil
NOT run properly on UNC computers; regardles of how they wil perform. on your
own computer.
• You are strongly advised to test your functions before submiting this asignment!
• This work must be completed on your own. Plagiarism and colusion are regarded as
very serious offences and wil be treated as such.
Information on Academic Misconduct Policy and Procedure can be obtained at:
http:/ww.nottingham.ac.uk/academicservices/qualitymanual/assesme
nt/academic-misconduct.aspx
Centre for English Language Education (CELE)
Module: CELEN046
Question 1 (Chinese zodiac signs)
The Chinese zodiac, known as Shēngxiào, is based on a 12-year cycle, each year in that cycle
relates to an animal sign. A typical 12-year cycle is shown in the table below. The patern
repeats, that is, 2024 wil be another year of the Dragon, and 201 was a year of the Rabit,
and so on.
Year Symbolic animal
2012 Dragon
2013 Snake
2014 Horse
2015 Shep/Goat
2016 Monkey
2017 Roster
2018 Dog
2019 Pig
2020 Rat
2021 Ox
2022 Tiger
2023 Rabit

Write a user-defined Octave function Mysign that reads a year from the user and displays the
animal sign associated with that year.
Your program should work for any year greater than or equal to zero.
[10]

Centre for English Language Education (CELE)
Module: CELEN046

Question 2 (Composite Magic Numbers)

Write a user-defined Octave function Mynumber which acepts two positive integers ! and
#, where !< #, as inputs and outputs al composite magic numbers in the range [!,#]
alongwith the frequency.
e.g. INPUT: !=1200 #=1300
OUTPUT:
The composite magic numbers in the range are:
1207, 1216, 1225, 1234, 1243, 1252, 1261, 1270, 1288
Frequency of composite magic numbers in the range is: 9
[20]

Notes:
a) Composite number: It is a number which has more than two factors.
e.g. += 10
Factors of + are: 1,2,5,10.

b) Magic number: It is a number in which the eventual sum of the digits is 1.
e.g. + = 28 is a magic number because 2 + 8 = 10 = 1 + 0 = 1.

c) Composite Magic number: It is a positive integer which is both composite and a magic number.


Centre for English Language Education (CELE)
Module: CELEN046

Question 3 (Matrix as two-dimensional list)

Write a user-defined Octave function Mymatrix which accepts a square matrix of order # as
input and:
a) Print the original matrix.
b) Print the order of the matrix.
c) Print the row and column position of the largest element of the matrix.
d) Print the row and column position of the second largest element of the matrix.
e) Sort the elments of each row in ascending order and print the new matrix B.
e.g. INPUT: A = [ 5, 1, 3; 7, 4, 6; 9, 8, 2 ]

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

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