CSE131 – 102nd Mid-term Exam (Solution)

$ 25.00
Category:

Description

C COMPUTER PROGRAMMING(I)
November 16, 2023

Exam rules
● Only Dev-C++ can be used for the exam.
● If your codes cannot be compiled by Dev-C++, it is considered as syntax error. ● Please save your codes as a c source file named after your student ID each problem.
ex. B123456789_a.c, B123456789_b.c, B123456789_c.c …
● If your codes cannot output the desired result, your points will be deducted.
● No reason for late submission.
● It is forbidden to search for information during the exam.
● The cheaters will get zero point.

Please design your program to complete the following problems.

a. (10 points)
Please let the user give a string, count the number of each English letter.
Note:
(1) The minimum string length is 1, and the maximum is 100.
(2) The string consists only of English letters.
(3) Both uppercase and lowercase are considered to belong to the same category.
(4) Your code should be able to input and output repeatedly.

Sample output:

(20
Pascal’s triangle is a special triangle that is named after the French mathematician Blaise Pascal. The numbers in Pascal’s triangle are placed in such a way that each number is the sum of two numbers just above the number.

Please let the user give an integer N, output the first N levels of Pascal’s triangle.
Note:
(1) 1 <= N <= 15
(2) Print each element using “%5d”.
(3) Print each whitespace character using “%5c”.
(4) Your code should be able to input and output repeatedly.

Sample output:

(30
Please let the user give an integer N as the length of the array, generate an array with all values between -99 and 99, then sort the array in ascending order through insertion sort or selection sort, and repeatedly perform binary search.
Note:
(1) 1 <= N <= 25
(2) Both sorting methods should be completed.
(3) If the user searches for 100, return to the beginning.
(4) Your code should be able to input and output repeatedly.

Sample output:

(20
Convolutional Neural Networks (CNNs) represent a powerful class of deep learning models designed for tasks involving visual data.
CNN uses filters or kernels to perform convolution operations to scan the image. These filters detect patterns in images such as edges, textures, or more complex features.

Taking the above figure as an example, the calculation process of convolution operation is as follows:

2*1 + 4*2 + 9*3 + 2*(-4) + 1*7 + 4*4 + 1*2 + 1*(-5) + 2*1 = 51
4*1 + 9*2 + 1*3 + 1*(-4) + 4*7 + 4*4 + 1*2 + 2*(-5) + 9*1 = 66
9*1 + 1*2 + 4*3 + 4*(-4) + 4*7 + 6*4 + 2*2 + 9*(-5) + 2*1 = 20 2*1 + 1*2 + 4*3 + 1*(-4) + 1*7 + 2*4 + 7*2 + 3*(-5) + 5*1 = 31

2*1 + 9*2 + 2*3 + 5*(-4) + 1*7 + 3*4 + 4*2 + 8*(-5) + 5*1 = -2

Assum you have 3 different filters like below:

Please generate a two-dimensional array of size 5*5 that all values between -10 and 10, then let the user to select a filter to perform the convolution operation repeatedly.
Note:
(1) Your code should be able to input and output repeatedly.

Sample output:

e. (10 points)
Please generate an array of length 15 with all values between -10 and 10, output the maximal and minimal values firstly, then the second maximal and the second minimal values, and so on.
Note:
(1) Your code should be able to input and output repeatedly.

Sample output:

f. (10 points)
Please let the user give a string, determine whether it is a palindrome.
Note:
(1) The minimum string length is 1, and the maximum is 100.
(2) Your code should be able to input and output repeatedly.

Sample output:

Reviews

There are no reviews yet.

Be the first to review “CSE131 – 102nd Mid-term Exam (Solution)”

Your email address will not be published. Required fields are marked *