# 程式設計(0425) ## 班級 學號 姓名 ### 陣列基礎 1. 輸入$n$個0~100的正整數,求平均數$\mu$和標準差$\sigma$。 $$\mu=\frac{1}{n}\sum_{i=1}^{n}{x_i}$$ $$\sigma=\sqrt{\frac{1}{n}\sum_{i=1}^{n}(x_i-\mu)^2}$$ 2. 使用篩法找出2~100的所有質數。 ### 陣列排序 3. 輸入$n$個0~100的正整數,使用氣泡排序法由大到小排序。 ```c= #include <stdio.h> #include <stdlib.h> #include <time.h> int main() { srand(time(NULL)); int a[10]; for (int i = 0; i < 10; i++) { a[i] = rand() % 101; printf("%4d", a[i]); } printf("\n"); int flag; do { flag = 0; for (int i = 0; i < 9; i++) { if (a[i+1] < a[i]) { int t = a[i+1]; a[i+1] = a[i]; a[i] = t; flag = 1; } } } while (flag == 1); for (int i = 0; i < 10; i++) { printf("%4d", a[i]); } printf("\n"); return 0; } ``` 4. 輸入$n$個0~100的正整數,求中位數。 5. 利用電腦亂數模擬擲骰子(1~6)100次,求眾數。 --- 作業繳交方式:寄E-mail 收件人:lenghs@cc.ncue.edu.tw 主旨:程式設計(0425) 附件:程式設計(0425) - HackMD.pdf 內文:本日上課心得(字數不限不得省略)
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up