# 程式設計(0328) ## 班級 學號 姓名 ### break & continue 1. 輸入正整數$n$,判斷是否為質數。 2. 輸入正整數$n$,求其標準分解式。 ### ACM格式輸入 **[ACM]輸入多組數據直到EOF** ```c= int a, b; while (scanf("%d %d", &a, &b) != EOF){ // a, b } ``` **[ACM]指定組數以及各組整數** ```c= int n; scanf("%d", &n); for (int i = 0; i < n; i++){ scanf("%d %d", &a, &b); // a, b } ``` **[ACM]不指定組數並指定結尾0 0結束** ```c= int a, b; while (scanf("%d %d", &a, &b) && (a || b)){ // a, b } ``` **[ACM]指定組數以及各組字串** ```c= #define LEN 80 int n; char str[LEN]; scanf("%d", &n); for (int i = 0; i < n; i++){ scanf("%s", str); // str } ``` **[ACM]多組字串以逗號分隔** ```c= #include <string.h> #define NUM 10 #define LEN 80 char temp[LEN], str[LEN]; while (scanf("%s", temp) != EOF){ char *ptr = strtok(temp, ","); while (ptr != NULL){ strcpy(str, ptr); // str ptr = strtok(NULL, ","); } } ``` 3. [ACM]輸入$n$個正整數,求其和。 4. [Game]設定本金初值$100,下注與電腦猜拳獲勝得兩倍押金,直到結束。 -- 作業繳交方式:寄E-mail 收件人:lenghs@cc.ncue.edu.tw 主旨:程式設計(0328) 附件:程式設計(0328) - HackMD.pdf 內文:本日上課心得(字數不限不得省略)