Skip to content

Instantly share code, notes, and snippets.

@BalicantaYao
Last active February 10, 2018 11:43
Show Gist options
  • Save BalicantaYao/5041ffd50c999c110844fec8b3d6f71b to your computer and use it in GitHub Desktop.
Save BalicantaYao/5041ffd50c999c110844fec8b3d6f71b to your computer and use it in GitHub Desktop.
1.給予 int x,請計算 y 值,其公式如下:
y = 3 * x^2 若 x < -1
y = x^3 + 3 * x - 3 若 -1 <= x <= 1
y = 2 * x + 3 若 x > 1
2.給予三角形三邊長(int)a,b,c,請判斷是直角,銳角,鈍角,或非三角形.
(註:假設邊長排序結果,a <= b <= c,則
直角(right triangle): c*c = a*a + b*b
鈍角(obtuse triangle): c*c > a*a + b*b
銳角(sharp triangle): c*c < a*a + b*b
非三角形(non triangle): a + b <= c)
3.給予三個Double a,b,c,
請求出其中最大(max,maximum)和最小者(min,minimum).
4.若計程車車資,其里程在1650公尺以下皆70元,
每超過350公尺加5元,不足350公尺以350公尺計算.
給予里程(mileage),算出車資(fee).
5.輸入正整數n,印出如下各種高為n的三角形(triangle)或四方形(square):
(假設n=5)
(a) (b) (c)
* * *
** ** ***
*** *** *****
**** **** *******
***** ***** *********
(d) (e)
***** *****
***** * *
***** * *
***** * *
***** *****
6.輸入一個整數N,列舉如下數列,直到數字超過N為止.
(a) 1,3,5,7,9,11,13,.....
(b) 1,2,4,7,11,16,22,29,.....
(c) 1,2,2,3,3,3,4,4,4,4,5,5,5,5,5,.....
7.設計一程式找出1到100間,所有能被7整除(7 divisable)的數.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment