This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:html'; | |
import 'dart:math' as Math; | |
CanvasElement canvas; | |
CanvasRenderingContext2D ctx; | |
int flag_w = 300; | |
int flag_h = 200; | |
num flag_w_uk = 300; | |
num flag_h_uk = 150; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import "dart:html"; | |
LBtoKG(num lb){ | |
return lb*0.45359237; | |
} | |
KGtoLB(num kg){ | |
return kg*2.20462262; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 下列 Dart 程式, 利用 Runge Kutta 迭代運算法, 解常微分方程式 | |
// 設 t 為時間, x 則設為物體的位移 | |
// 假設要解 F=ma 的單一質量加上彈簧 (常數為 k) 與黏滯阻尼 (常數為 b) | |
// f 為沿位移方向的施力 | |
// dx/dt = v, dv/dt = (f-kx-bv)/m | |
// dx / dt = (t - x)/2, 起始值 t0=0, x0=1, 求 t=2 時的 x 值 | |
// | |
// 已知起始值 t0 與 x0 後, 可以利用下列 rungeKutta 函式, 以 | |
// h 為每步階增量值, 求 dxdt 常微分方程式任一 t 的對應值 x | |
// 定義函式 rungeKutta, 共有四個輸入變數 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 下列 Dart 程式, 利用 Runge Kutta 迭代運算法, 解常微分方程式 | |
// 設 t 為時間, x 則設為物體的位移 | |
// dx / dt = (t - x)/2, 起始值 t0=0, x0=1, 求 t=2 時的 x 值 | |
// | |
// 已知起始值 t0 與 x0 後, 可以利用下列 rungeKutta 函式, 以 | |
// h 為每步階增量值, 求 dxdt 常微分方程式任一 t 的對應值 x | |
// 定義函式 rungeKutta, 共有四個輸入變數 | |
rungeKutta(t0, x0, t, h) { | |
// 利用步階增量值 h 與 t 的起始及終點值 | |
// 計算需要迭代的次數 n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 在所有函式定義外圍所宣告的變數, 稱為全域變數, 有效範圍包含各函式內部與外部 | |
// for 迴圈所使用的索引值, 宣告為整數 (integer) | |
int i; | |
// 累加起始值 start 宣告為整數, 且設為 1 | |
int start = 1; | |
// 累加終止值 end 宣告為整數, 且設為 10 | |
int end = 10; | |
// 累加總數值 sum 宣告為整數 | |
int sum; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int i; | |
int sum; | |
main(){ | |
sum = 0; | |
for(i=1;i <= 10 ;i++){ | |
sum += i; | |
print("$sum"); | |
} | |
print('sum = $sum'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
print("哈囉!"); | |
} |