Question: Echo 360 Course groups: Obj- School of Compute School of Compute Practical 2-Due 11s x Lecture03pdf: obje+ https://myuni.adelaide.edu.au/courses/4592 7/pages/practical-2-due-11-55pm-friday-week-2?module item id-1461590 1. Starting problems These

 Echo 360 Course groups: Obj- School of Compute School of Compute

Practical 2-Due 11s x Lecture03pdf: obje+ https://myuni.adelaide.edu.au/courses/4592 7/pages/practical-2-due-11-55pm-friday-week-2?module item id-1461590 1. Starting

problems These first problems are all based on the mathematical concept of

a matrix common use of this structure! Don't worry if you're a

Echo 360 Course groups: Obj- School of Compute School of Compute Practical 2-Due 11s x Lecture03pdf: obje+ https://myuni.adelaide.edu.au/courses/4592 7/pages/practical-2-due-11-55pm-friday-week-2?module item id-1461590 1. Starting problems These first problems are all based on the mathematical concept of a matrix common use of this structure! Don't worry if you're a bit rusty on matrices, we explain everything below Definition: a matrix is a rectangular array of data. It can be square or rectangular Examples: 113 104 because it's a great fit for doing multi-dimensional arrays in Ct+ and isa very This matrix has 2 rows and 3 columns This matrix has 2 rows and 2 columns (and is an Identity matrix, see below) 4 5 This matrix has 4 rows and 2 columns Note that there are no empty cells, just zero cells, in these numerical examples. 1-1. Given a matrix of integers, return the sum of the elements along the main diagonal (top left bottom right) Signature: Int diagonal (int array[4114]) Note. This function should be placed in function-1-1.cpp and the matching main function in main-1-1.cpp) 1-2. Given a matrix of integers with 10 rows and 10 columns, write a function and program to determine if the matrix is an identity matrix or not Return a 1 if it is an identity matrix and a O if not. (Definition: An identity matrix is one with 1's down the main diagonal and O's elsewhere) Echo 360 Course groups: Obj xSchool of Computer Practical 2-Due 11. School of Compute, Lecture03.pdf Obje x + * ttps/myuni.adelaide.edu.au/courses/45927/pages/practical-2 due-11-55pm-friday week 22module item id -1461590 1-2. Given a matrix of integers with 10 rows and 10 columns, write a function and program to determine if the matrix is an identity matrix or not Return a 1 if it is an identity matrix and a O if not. (Definition: An identity matrix is one with 1's down the main diagonal and'o's elsewhere) Signature: int identity(int array[18][1]) 1-3 Given a matrix of integers, count the amount of times each number 0-9 appears. Print out your results on one line irn xes;7:nunber of sevens ;8:nunber of ei e:nunber of zeros;1:number of ones;2:number of twos;3:nunber of threes ,4:number of fours;5:number of fives;6:number of si ghts,9:number of nines For example, if you are passed an identify matrix,it contains 12 zeros and 4 ones and no other numbers from 0 to 9, your output would 0:12;1:4;2:0,3:0,4:0,5:0:6:0,7:e:8:0,9:0 Note the colons and semi-colons. Signature: vold count numbers(int array[4]14]) 1-4 Given a matrix, print out the scaled version of the should be printed by row, with matrix, where you multiple every element in the matrix by the same numeric value. Elements a space separating elements on a row, and a newline character separating rows. Example: int scale 3 i int threebythree[3][31-((e,1,2),(1,4,5),(6,7,8)) i print-scaled natrix(threebythree , scale) ; This should produce the following output: 0 36 9 14 15 18 21 24 Signature: void print scaled patrix(int array 3113],int scale) o S 20193/14 Echo 360 xCourse groups: Obje School of Computer Practical 2 . Due 1 1 . School of Computer Lecture03.pdf: Obje uni.adelaide.eduau/courses/45927/pages/practical- 2-due-11-55pm-friday week 22module item id-1461590 1-5 Given two two-dimensional arrays, add them together and print the result as in 1-4 above. What relationship needs to be between the sizes of the two matrices? Example: int matrixi[3]I3] e,1,2),(3,4,5),(6,7,8)1 int matrix2[3]13 e,e,e),(2,2,2),(-5,-4,8)) ; print summed matrices(matrixl,matrix2) This should produce the following output: e 1.2 5 6 7 1 3 16 Signature: void print_ summed matrices(int array1[3]31,int array2[3](3]) 2. Medium problems ite a function that transforms it into binary, and prints out the result. You may assume that the string contains 2-1. Given at least 1 and no more than 9 decimal digits. The output should only include the binary digits followed by a new line. C++11 string library. If you need to compile with C++11, include Hint: You might need to convert a string to integer. Have a look at the stoi(string) in the the compilation flag-std-c++11 in your compile command 5ignature: vold print_as binery(std:istring decinal nunmber) 2-2. Given a binary number represented as an array, write a function that takes the array and its size as a parameter, and returns the integer value You may assume that there are at least 1 and no more than 30 numbers in the array and that all the values are either 0 or 1. The array is ordered with most significant binary digit at the start (index 0) and the least significant digit at the end. Signature: int binary to nusber (int binary digits(), Int nunber of digits) wd, Echo 360 Course groups: Obj School of Computer adelaide.edu.au/courses/45927/pages/practical 2-due-11-55pm-friday-week- 2?module item id-1461590 X Practical 2 . Due 11- School of ComputerLecture03.pdf: Obje 2-3. Given an array of integers, write a function to calculate the sum of the elements if it is a pali function must return -2. Your function must call separate functions to check whe elements. If the length is 0 or negative each function must return-1 or false as its result ndrome array. If it is not a palindrome array, your ther or not the array is a palindrome and t calculate the sum of its Signature: int sum if e pal indrome(int integerst), int length) Signature: bool is a palindrone(int integerstl, int length) Signature: Int sum elenents(int integers[l, int length) 2-4. Given an array of integers, write a function to determine its maximum and minimum elements and then return their sum. Your function must call separate functions to identify the maximum and minimum elements. If the length is 0 or negative each function must return -1 as its result. Signature: int sum_nin and max(int integors[1, int length) Signature: int nax integer(int integers[], int length) Signatyre: int min integer(int intsgers[l, int length) 3. Tricky problems ems, we are giving you a free hand at writing the signature of your functions. Follow the templates from the easier problems, and ask set in the context of a supermarket checkout. There is only one checkout with a single line af context of a for help if unsure! The following two problems are customers each with items they are wanting to buy Note: The web submis 3-1. Write code to capture the scenario: at the checkout, the customer who is first in the ssion system will ignore these two programs so no marks will be awarded for them even if you submit them queue pays an amount equal to the value of his/her products leaves the supermarket. The next customer in the queue is then served. For each customer in the queue (you have initialised the 10 customers), print out how much they have to pay 10 customers in it. A new customer 3-2 2. Write code to capture the scenario: you have been serving customers for a while and your queue no longer has arrives at the checkout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!