Computer Programming - C - : Mid-Term Exam For 02
Computer Programming - C - : Mid-Term Exam For 02
Lee 2005/11/22
Notice 1. Plagiarism, the use of USB flash drive and discussion are prohibited. 2. Students only can take pen and textbook in the classroom. 3. In the programming examination, there are five problems, and the naming of your program is defined in the following format. If your student ID is b94902001, your programs name for problem 1 is B94902001_P1.c, and B94902001_P2.c for problem 2. If you want to resubmit your program, please name it by version, like 4. B94902001_P1_ver1.c for problem 1 version 1. TAs will use USB flash drive to collect your programs in our program spool.
pp. 1
For example, if your family use 330 degree a month, the cost of summer use is 110 * 2.1+ (330 - 110) * 2.7 = 825 And the corresponding cost of non-summer use is 110 * 2.1+ (330 - 110) * 2.4 = 759 You are asked to show the bills in both summer use and non-summer use. Sample Input Please input the degree of electric consumption: 330 Sample Output 330 degree: 825 (summer use), 759 (non-summer use)
pp. 2
two
AT is defined by exchanging all elements aij with Now, you are asked to
implement these two functions and write your main program by calling these two 1 functions to compute T . A Sample Input 1 Please input the size of a square matrix: 5 Please input values for a square matrix:
1 3 1 1 4
0 1 3 1 1
2 1 1 2 2
3 2 1 3 1
4 1 1 1 3
1 : AT
The matrix of
undefined
Sample Input 2 Please input the size of a square matrix: 5 Please input values for a square matrix:
1 3 1 1 4
1 1 3 1 1
2 1 1 2 2
3 2 1 3 1
4 1 1 1 3
1.00 1.00
0.33 1.00
1.00 0.33
1.00 1.00
0.25 1.00
pp. 3
A(n) is the times of calling P(0) when calculating P(n) recursively. Please print the recursive form of A(n) and then calculate it, given n (0 n 20 . 20)
Sample Input Please input a non-negative number: 5 Sample Output The recursive form of A series is ??? A(5) = ???
pp. 4
60
15
78
30
60 15
78
30 is 78
pp. 5
the two travel points and more than zero if these two travel points are adjacent. Now, the CSIE travel agent provides 7 travel points. the end point, and then find the corresponding cheapest tour.
Cost Matrix
TP1 TP1 TP2 TP3 TP4 TP5 TP6 TP7 TP2 TP3 TP4 TP5 TP6 TP7
2000 0 0 0 0 1000 0
0 0 1000 1000 0 0 0
2000 0 0 0 0 0 0
2000 0 0 0 0 1000 0
0 0 1000 1000 0 0 0
2000 0 0 0 0 0 0
Please input the start point: 1 Please input the end point: 4 Sample Output The cheapest tour from 1 to 4: 1 -> 3-> 6 -> 4 The cost : 4000
pp. 6