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

作者: installbtien (周孑堬)   2020-03-23 13:06:45
課程名稱︰計算機程式
課程性質︰化工系必修
課程教師︰徐振哲
開課學院:工學院
開課系所︰化工系
考試日期(年月日)︰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.)
作者: CaCO2 (馬英九還我牛)   2020-07-12 12:44:00
這樣未來澳洲打工度假根本撈不到錢啊
作者: f19890230   2020-07-12 12:44:00
這樣說也沒錯,認同鈣二氧化碳大大
作者: CaCO2 (馬英九還我牛)   2020-07-12 12:45:00
那個,我是碳酸鈣啦ww
作者: f19890230   2020-07-12 12:45:00
碳酸鈣是CaCO3喔
作者: BadNose   2020-07-12 12:45:00
樓上文組
作者: installbtien (周孑堬)   2020-04-07 23:19:00
原來樓上跟我同一個班 他發回來給我們看的時後我有拍起來

Links booklink

Contact Us: admin [ a t ] ucptt.com