1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

Supplementary tasks introduction to computers and programming

6 1 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 6
Dung lượng 189,22 KB

Nội dung

Chapter 1 Introduction to Computers and Programming A Review A 1 What is a computer? Give at least 3 examples A 2 What is a program? Give at least 3 examples A 3 What is a programming language? Give a[.]

Chapter 1: Introduction to Computers and Programming A Review: A.1 What is a computer? Give at least examples A.2 What is a program? Give at least examples A.3 What is a programming language? Give at least examples A.4 What is programming? List several supporting tools for programming A.5 Describe the main features of the C language A.6 Why we need a compiler for C programs? A.7 Describe the programming tasks A.8 What is source code? A.9 What is an algorithm? Distinguish an algorithm from a program A.10.What is pseudo code? A.11.What is a flowchart? A.12.Make a comparison of different representation types of an algorithm: pseudo code, flowchart, real code in a programming language B Practice: B.1 Write the solution of each following problem B.1.1 Given a positive integer number, check if the number is an odd Input1: Output1: an odd Input2: Output2: not an odd B.1.2 Given a positive integer number, find the Fibonacci number series whose size is the given number Input1: Output1: 1 Input2: Output2: 1 B.1.3 Given a positive real number, find its closest integer number Input1: 1.2 Output1: Input2: 2.0 Output2: Input3: 3.7 Output3: B.1.4 Given a vector in the 2-dimensional space, find its normalized vector, which has the same direction but size of Input1: x = 1, y = Output1: x = 0.447214, y = 894427 Input2: x = 2, y = Output2: x = 0.371391, y = 0.928477 Input3: x = 0, y = Output3: x = 0, y = B.1.5 Given two points in the 2-dimensional space, find their Euclidean distance Input1: x1 = 1, y1 = 2, x2 = 3, y2 = -1.5 Output1: 4.031129 Input2: x1 = 2, y1 = 2, x2 = 0, y2 = Output2: 2.828427 B.1.6 Given two vectors in the 2-dimensional space, check if the angle between these two vectors is a right angle (an angle of 90 degrees) Input1: x1 = 1, y1 = 2, x2 = 3, y2 = -1.5 Output1: right angle Input2: x1 = 2, y1 = 2, x2 = 0, y2 = Output2: not a right angle Input3: x1 = 2, y1 = 1, x2 = 1, y2 = -1 Output3: not a right angle, angle = 71.565112 degrees B.1.7 Given n positive real numbers, find all the maximum numbers Input1: n = 5; {2.9, 3.1, 1.2, 4.6, 5.2} Output1: the number at the 5-th position: 5.2 Input2: n = 5; {2.9, 5.2, 1.2, 4.6, 5.2} Output2: the numbers at the 2- and 5-th positions: 5.2 B.1.8 Given n points in the d-dimensional space, find the nearest points of another given query point in the same space based on their Euclidean distances Input1: n = 5, d = 1, x1 = 1, x2 = 3, x3 = 8, x4 = 16, x5 = 8, qx = Output1: x3 = 8, x5 = Input2: n = 5, d = 2, x1 = 1, y1 = 1, x2 = -1, y2 = 2, x3 = -3, y3 = -3, x4 = 9, y4 = 5, x5 = 3, y5 = 3, qx = 0, qy = Output2: x1 = 1, y1 = Input3: n = 6, d = 2, x1 = 1, y1 = 1, x2 = -1, y2 = 2, x3 = -3, y3 = -3, x4 = 9, y4 = 5, x5 = 3, y5 = 3, x6 = -1, y6 = 1, qx = 0, qy = Output3: x1 = 1, y1 = 1, x6 = -1, y6 = B.1.9 Given n positive real numbers, find all the numbers greater than another given positive real number Input1: n = 5, {2.9, 5.2, 1.2, 4.6, 5.2}, 3.4 Output1: 5.2, 4.6, 5.2 Input2: n = 6, {2.9, 5.2, 1.2, 4.6, 5.2, 3.4}, 3.4 Output2: 5.2, 4.6, 5.2 B.1.10 Given two strings, check if the second string is contained by the first string Input1: s1 = "computer programming", s2 = "programming" Output1: yes Input2: s1 = "computer programming", s2 = "computers" Output2: no B.1.11 Given a paragraph and a word, find the frequency of the given word in the given paragraph Input1: s1 = "computer programming with the C programming language", s2 = "programming" Output1: Input2: s1 = "computer programming with the C programming language", s2 = "language" Output2: Input3: s1 = "computer programming with the C programming language", s2 = "computers" Output3: B.1.12 Given a paragraph, find the words that occur the most frequently Input1: s1 = "computer programming with the C programming language" Output1: "programming": Input2: s1 = "computer programming with the C programming language or any other language that you prefer" Output2: "programming": 2, "language": B.1.13 Given n real numbers, find their median A median of a sorted sequence of elements is defined as the middle element If the number of elements is an odd, a median is the same as the center element Otherwise, a median is an average of the two center elements B.1.14 Given the information of n students including name, identifier (ID), class name, and class ID, assign each student into a class corresponding to the initial character of his/her name Particularly, a class named A_H with the students whose names start with A, B, , H has a class ID = 1, another class named I_S with the students whose names start with I, J, , S has a class ID = 2, and another one named T_Z with the students whose names start with T, U, , Z has a class ID = After updating the information of each student, print their information grouped into three corresponding classes B.1.15 Given the information of n products including name, stock identifier, stock number, and unit price, and additionally given the information of the sold products including name and sold quantity, update the stock number of each product in the first list and update the amount of money of each sold product in the second list which is calculated as unit price * sold quantity B.2 Write pseudo code of the aforementioned solution of each problem B.3 Draw their corresponding flowcharts

Ngày đăng: 11/04/2023, 18:46