[試題] 107-1 林達德 計算機程式語言 期中考

看板NTU-Exam作者 (UJ)時間5年前 (2018/11/30 02:01), 5年前編輯推噓1(102)
留言3則, 3人參與, 5年前最新討論串1/1
課程名稱︰計算機程式語言 課程性質︰大一必修 課程教師︰林達德 開課學院:生農學院 開課系所︰生機系 考試日期(年月日)︰2018.11.08 考試時限(分鐘):120 是否需發放獎勵金:是 試題 : Problem 1:(20 points) Briefly explain the following terms: (1) ASCII (2) pass by reference (3) coercion (4) function overload (5) machine language (6) syntax error (7) function prototype (8) nested loops (9) continue (10) global varaible Problem 2:(10 points) What is output by the following code segment? for( int i=0; i<5; i++){ for( int j=0; j<9; j++){ if( j%3 == 0) cout << '#'; else cout << '$'; } cout << endl; } Problem 3:(10 points) What is the output of the following program? #include <iostream> using namespace std; void teststat(); int k = 20; int main() { int count; int k=60; for(count=0; count<5; count++) teststat(); cout MM "The value of k is " << k << endl; return 0; } void teststat() { static int num = 0; cout << "The value of num is " << num << endl; cout << "The value of k is " << k << endl; num++; k++; return; } Problem 4:(10 points) Write a program that calculates and outputs the prime numbers from 2 tp N. The number N is to be input by the user and the output is on the screen. Problem 5:(10 points) Write a function that computes and returns the value of cos(x) by using the following formula. The arguments of this function are the value of x (in radians) and the number of terms, n, of the series. x^2 x^4 x^6 cos(x) = 1 - ----- + ----- - ----- + ....... 2! 4! 6! Problem 6:(10 points) A positive integer is a perfect number if it is equal to the sum of all of its factors, including one but excluding itself. For example, 6 is a perfect numb- er, since 6 = 1 + 2 + 3, and 1, 2, and 3 are factors of 6. Design a PerfectNumber(long int Num) function that determines whether the sup- plied number Num is a perfect number. Write a progrma to find all perfect num- bers between 1 and 10000 by calling the function PerfectNumber(long int Num). What is the greatest perfect number you can find? Problem 7:(10 points) The greatest common divisor(GCD) of two integers is the largest integer that evenly divides into each of the two integers. Writhe a function gcd that retu- rn the greatest common divisor of two integers. Problem 8:(10 points) Write a program that takes an 5-digit integer value and returns the number with its digit reversed. For simplicity, use integer numbers that do not cont- ain zeros. For example, given the number 32768, the program should return 86723. Program 9:(10 points) Write a function that will merge the contents of two sorted (ascending order) arrays of type double values, storing the results in an array output parameter (still in ascending order). The function should not assume that both its input parameter arrays are the same length but can assume that one array does not contain two copies of the same value. The result array should also contain no duplicate values. First array Second array -10.3 | -1.7 | 3.6 | 7.2 | 8.9 -1.7 | 3.1 | 7.2 | 8.1 Result array -10.3 | -1.7 | 3.1 | 3.6 | 7.2 | 8.1 | 8.9 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.112.25.99 ※ 文章網址: https://www.ptt.cc/bbs/NTU-Exam/M.1543514461.A.F9E.html

11/30 07:44, 5年前 , 1F
修課學生推~~~
11/30 07:44, 1F

12/05 17:27, 5年前 , 2F
1-8是nested吧
12/05 17:27, 2F
※ 編輯: unmolk (140.112.94.113), 12/06/2018 16:48:36

12/06 16:48, 5年前 , 3F
已更正Q
12/06 16:48, 3F
文章代碼(AID): #1S02bT-U (NTU-Exam)