[試題] 108-1 徐振哲 計算機程式 第二次期中考

看板NTU-Exam作者 (IU)時間4年前 (2020/03/23 13:06), 4年前編輯推噓1(102)
留言3則, 2人參與, 4年前最新討論串1/1
課程名稱︰計算機程式 課程性質︰化工系必修 課程教師︰徐振哲 開課學院:工學院 開課系所︰化工系 考試日期(年月日)︰2019/11/28 考試時限(分鐘):忘了 試題 : Problem 1 (15 points): Make the following array of plots: ┌─────────────────────────┐ Create the following function: z=x*sin(x)exp(-y^2) use 3D surface plot with contour, plot the above function between x=0~2pi and y=-2~2 ├─────────────────────────┤ Plot the following points with black circles and y=x^2 with a red solid line for x=0~5 ┌──┬──┬──┬──┬──┬──┐ │ x │ 0 │ 1 │ 2 │ 3 │ 4 │ ├──┼──┼──┼──┼──┼──┤ │ y │ 1 │2.5 │ 4 │9.5 │ 17 │ └──┴──┴──┴──┴──┴──┘ ├─────────────────────────┤ plot y=x^3*exp(x) and y=x*exp(x) on the same plot using solid and dashed lines, respectively, between -1 and 3. └─────────────────────────┘ Problem 2 (15 points): Do the following in ONE*.m file and function file and properly display results: (i) (5 points) Ask the user to input a positive integer "m". Find and display minimum "n" such that 1*2*3+2*3*4+3*4*5+...+n*(n+1)*(n+2)>m. (ii) (5 points) Solve the following equation sets: x+3y-z=3 2x-3y+3z=4 y+z=5 (iii) (5 points) Create the following function, and then plot for x=-1~5 y=|x| for x<1 y=exp(x)*sin(x) for 1<=x<3 y=log(x) for x>=3 Problem 3 (20 points): Do the following using ONE*.m file: (i) (10 points) Ask the user to input a positive even integer "n" greater than 2, if the input number is not a positive even integer, display "Invalid input", then ask the user to input it again for up to THREE TIMES. For the fourth wrong input, display "bye-bye" then exit the code. (ii) (10 points) Find show the pair of a and b, such that a and b are both prime numbers and a+b=n. Problem 4 (20 points): Fibonacci series is a series starts from a1=0 and a2=1, and each term equals the sum of the previous two terms, a_n+2_ = a_n+1_ + a_n_ such that the a1~a7 are 0,1,1,2,3,5,8, respectively. Answer the following questions (You are NOT allowed to use functions related to Fibonacci): (以底線表示下標) (i) (10 points) Ask the user to input a positive integer m, and display a_m_. (ii) (10 points) Plot the ratio of a_n+1_/a_n_ vs. n for n=1~200. Also draw a horizontal line for y=(1+sqrt5)/2. (Note: a_n+1_/a_n_ approaches (1+sqrt5)/2 when n approaches infinite) Problem 5 (15 points): In ONE*.m file, use the following methods to find and properly display approximated pi: pi_1, pi_2, pi_3 (i) (5 points) pi_1: Calculate the approximate area of the following curve: y=sqrt(1-x^2) between 0and 1 with n=150. You may use either A or B. https://i.imgur.com/Mvl0ANI.jpg
(ii) (5 points) Create two arrays AA and BB, each has 1500 elements of random number between -1 and 1. C=AA.^2+BB.^2. Use "mask" to calculate the fraction of elements in C that are less than 1. Use this fraction to calculate pi_2. (iii) (5 points) Use 20 terms approximation to calculate approximated pi: pi_3 (you are NOT allowed to type in terms manually.) π 1 1 1 1 ─ = 1 - ─ + ─ - ─ + ─ ...... 4 3 5 7 9 Problem 6 (10 points): Use "rand" to generate a random positive integer N below 99999, then create a 1*M array AA with 0, 1, and 2, where AA represent N as a ternary number (三進位數). For example, N=5, AA=[1 2]; N=24, AA=[2 2 0]. Properly display AA and N (not necessarily to be in the same line.) Note: You are NOT allwed to use ANY Matlab functions for conversion between binary, decimal, and hexadecimal numbers such as "bi2de", "bin2dec", "dec2bin", "dec2hex", or "de2bi". Problem 7 (5 points, Answer on THIS exam sheet): Write down your comments and suggestionsto this course (for example: course, lecturer, exams, and teaching assistant.) --

07/12 12:44,
這樣未來澳洲打工度假根本撈不到錢啊
07/12 12:44

07/12 12:44,
這樣說也沒錯,認同鈣二氧化碳大大
07/12 12:44

07/12 12:45,
那個,我是碳酸鈣啦ww
07/12 12:45

07/12 12:45,
碳酸鈣是CaCO3喔
07/12 12:45

07/12 12:45,
...所以我是鈣二氧化碳Orz
07/12 12:45

07/12 12:45,
樓上文組
07/12 12:45
-- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.112.236.34 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/NTU-Exam/M.1584940010.A.2EA.html ※ 編輯: installbtien (140.112.236.34 臺灣), 03/23/2020 13:07:13

04/07 19:18, 4年前 , 1F
老師不是不發回題目嗎 你怎麼全背的XDD
04/07 19:18, 1F

04/07 23:19, 4年前 , 2F
原來樓上跟我同一個班 他發回來給我們看的時後我有
04/07 23:19, 2F

04/07 23:19, 4年前 , 3F
拍起來
04/07 23:19, 3F
文章代碼(AID): #1UU4FgBg (NTU-Exam)