You are on page 1of 2

HCM UTE MID-TERM TEST: INTRO TO PROGRAMMING

Faculty for High Quality Subject ID: INPR104285E Semester 1 – 2021-2022


Training Test date: 03/12/2021 Duration: 120 mins
Total pages: 02.
Test ID: 01 Book-open, laptop use allowed.

General instructions:
 Every problem is solved and saved in ONE CPP file, named CAUx.CPP (with x
as the ordinal number of that problem).
Mỗi câu viết thành 01 tập tin CPP đặt tên dạng CAUx.CPP (với x là số thứ tự
của câu hỏi trong đề).
 At the beginning of every CPP file, comment your full name, student ID, date of
birth and class ID.
Đầu mỗi tập tin .CPP phải ghi chú đầy đủ các thông tin: họ tên, mã số sinh viên,
ngày tháng năm sinh, lớp.
 When submitting, only copy the CPP files into a folder named
StudentID_FullName and compress it into a RAR or ZIP file.
Khi nộp bài, sinh viên chỉ nén các tập tin mã nguồn CAU1.CPP, CAU2.CPP và
CAU3.CPP thành 01 tập tin .ZIP hoặc .RAR với tên theo dạng MSSV_HoTen
(không dấu).

Problem 1: (3 points) Write a complete program meeting the following


requirements (Hãy viết chương trình thực hiện các công việc sau):
a) (1p) Input a positive integer n from the keyboard (1<n<10); if the input value
is not compliant to the rule, ask the user to input again until the rule is
satisfied (Nhập 1 số nguyên dương 1<n<10; nếu không thỏa thì yêu cầu nhập
lại cho tới khi thỏa mới thôi).
b) (2p) Count and print out the number of prime numbers that have n digits (Đếm
và in ra số lượng các số nguyên tố có đúng n chữ số).

Problem 2: (5 points) Write a complete program meeting the following


requirements (Hãy viết chương trình thực hiện các công việc sau):
a) (1p) Input an integer array with N elements, then ouput that array onto the
console screen (Nhập từ bàn phím và in ra màn hình 1 mảng số nguyên có N
phần tử).
b) (1.5p) Check if the array has more than 50% of the elements whose value is
greater than the average of the whole array or not (Kiểm tra và cho biết mảng
có chứa hơn 50% số phần tử mang giá trị lớn hơn giá trị trung bình của mảng
không).
Ex: a 1 3 5 7 9
The AVG = 5.0, 2 elements greater than 5  No
c) (1.5p) Find and print out the element that has most positive dividents, together
with its number of positive dividents. In case there are more than one such
elements, just print out the first one. (Tìm và in ra phần tử có nhiều ước số
dương nhất, cùng với số lượng ước số dương của nó. Trong trường hợp có
nhiều hơn một phần tử như vậy, chỉ cần in ra phần tử đầu tiên).
Ex: a 8 2 20 18
 Result is 20, with 6 dividents
d) (1p) Delete the second prime number from the array (if any); print out the
resulting array (Xóa số nguyên tố xuất hiện ở vị trí thứ nhì ra khỏi mảng (nếu
có); in mảng kết quả ra màn hình).
Problem 3: (2 points) Write a complete program meeting the following
requirements (Hãy viết chương trình thực hiện các công việc sau):
a) (1p) Declare and input values for a matrix with size of dxc, then output it onto
the console screen. (Khai báo và nhập một ma trận cấp dxc từ bàn phím, sau
đó in ma trận vừa nhập ra màn hình).
b) (1p) Check if EACH ROW of the matrix is in ascending order or not. (Kiểm
tra và cho biết tất cả các dòng của ma trận đều có thứ tự tăng dần hay
không).

-THE END-

Note: No more explanations are allowed.


Day… month … year 2021
DEAN Lecturer

You might also like