You are on page 1of 2

HCM UTE FINAL TEST: INTRO TO PROGRAMMING

Faculty for High Quality Subject ID: INPR104285E Semester 1 – 2017-2018


Training Test date: 19/12/2017 Duration: 90 mins
Total pages: 02.
Test ID: 01 Book-open, laptop use is allowed.

General instructions:
 Save your files on an USB drive; or in folder D:\LUUBAI if you are using a
computer in the lab. Every problem is solved and save in ONE CPP file, named
CAUx.CPP (with x as the ordinal number of that problem).
Sinh viên lưu bài trên USB hoặc D:\LUUBAI nếu làm bài trên máy tính của
phòng máy. 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 real number x and a positive integer N so that its value is greater
than or equal to 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ố thực x và 1 số nguyên
dương 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) Calculate the value of the following expression (Tính và in ra màn hình
giá trị của biểu thức sau).

Problem 2: (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 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) (1p) Delete the second prime number from the array (if there are at least 2
prime numbers in the array. (Xóa số nguyên tố thứ nhì ra khỏi mảng, nếu
mảng có chứa từ 2 số nguyên tố trở lên).
c) (1p) Find the element with greatest sum of all its digits. (Tìm và in ra phần tử
có tổng các chữ số lớn nhất).
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) (0.5p) Declare and input values for a square nxn matrix, then output it onto
the console screen. (Khai báo và nhập một ma trận vuông cấp từ bàn phím,
sau đó in ma trận vừa nhập ra màn hình).
b) (1.5p) Check if every row of the matrix is a permutation of the collection {1,
2, …, n} or not. (Kiểm tra xem mỗi dòng của ma trận đều là một hoán vị của
tập {1, 2, …, n} hay không ).
Ex: 2 1 4 3
3 2 1 4
2 4 1 3
4 3 2 1
Problem 4: (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) (0.5p) Declare and input value for a string containing no more than 100
characters. (Khai báo và nhập một chuỗi ký tự có độ dài không quá 100).
b) (1.5p) Find and print out the first WORD that contains 2 or more vowels.
Vowels include A, E, I, O, U, Y, a, e, i, o, u and y. In case there is no such
word, inform the user. (Tìm và in ra TỪ đầu tiên có chứa từ 2 nguyên âm trở
lên. Nguyên âm gồ các ký tự A, E, I, O, U, Y, a, e, i, o, u và y. Nếu chuỗi
không có từ nào thỏa thì thông báo cho người dùng biết).
Ex: Input: Le Cong Tuan Anh
Output: Tuan
-THE END-

Note: No more explanations are allowed.


Day……. month …… year 2017
DEAN Lecturer

You might also like