氣泡排序 #include <stdio.h> int main() { int arr[] = { 22, 34, 3, 32, 82, 55, 89, 50, 37, 5, 64, 35, 9, 70 }; int len = (int) sizeof(arr) / sizeof(*arr);

Size: px
Start display at page:

Download "氣泡排序 #include <stdio.h> int main() { int arr[] = { 22, 34, 3, 32, 82, 55, 89, 50, 37, 5, 64, 35, 9, 70 }; int len = (int) sizeof(arr) / sizeof(*arr);"

Transcription

1 氣泡排序 #include <stdio.h> int main() int arr[] = 22, 34, 3, 32, 82, 55, 89, 50, 37, 5, 64, 35, 9, 70 ; int len = (int) sizeof(arr) / sizeof(*arr); int i, j, temp; for (i = 0; i < len - 1; i++) for (j = 0; j < len i; j++) if (arr[j] > arr[j + 1]) temp = arr[j]; arr[j] = arr[j + 1]; arr[j + 1] = temp; for (i = 0; i < len; i++) printf("%d ", arr[i]);

2 河內塔 #include<stdio.h> #include<stdlib.h> void towers(int n,char source,char aux,char dest) static int step=0;// 靜態 int 變數 printf("towers( %d, %c, %c, %c ) \n",n,source, aux, dest); if (n==1)// 特例 printf("\t\t\t\t\tstep %d : Move from %c to %c \n",++step,source,dest); else// 一般式 towers(n-1, source, dest, aux); printf("\t\t\t\t\tstep %d : Move from %c to %c \n",++step,source,dest); towers(n-1, aux, source, dest); int numdisks; printf("please enter number of disks:"); scanf("%d",&numdisks); printf("start Towers of Hanoi\n\n"); towers (numdisks, 'C', 'B', 'A'); // 碟子數量起點終點 ( 目的 ) 輔助 (temp)

3 二維陣列指標 #include<stdio.h> #include<stdlib.h> #include<iostream> using namespace std; int main() int a[3][3]=1,2,3,4,5,6,7,8,9; int i=0,j=0; printf("a=%d\n",a); printf("&a=%d\n",&a); printf("*a=%d\n",*a); printf("a[0]=%d\n",a[0]); printf("&a[0]=%d\n",&a[0]); printf("*a[0]=%d\n",*a[0]); printf("a[0]=%d\n",&a[0]); printf("a[1]=%d\n",&a[1]); printf("a[2]=%d\n",&a[2]); for(i=0;i<=2;i++) for(j=0;j<=2;j++) printf("%d",*(*(a+i)+j)); printf("\n");

4 記憶體空間範例 #include <iostream> #include <stdlib.h> using namespace std; int *ptri; double *ptrd; printf("sizeof(ptri)=%d\n",sizeof(ptri)); printf("sizeof(ptrd)=%d\n",sizeof(ptrd)); printf("sizeof(*ptri)=%d\n",sizeof(*ptri)); printf("sizeof(*ptrd)=%d\n",sizeof(*ptrd)); 函式傳陣列 #include<stdio.h> #include<stdlib.h> #define SIZE 4 void show(int arr[]); int A[SIZE]=5,3,6,1; printf(" 陣列的內容為 : "); show(a); void show(int arr[]) int i; for(i=0;i<size;i++) printf("%d ",arr[i]); printf("\n");

5 指標範例 #include<stdio.h> #include<iostream> int main() int a=0;// 空間大小 printf("a 的地址是 %d\n",&a);// 取地址 int *ptr;// 指標 pointer ptr=&a;//a 的地址餵給 ptr printf("*ptr=%d\n",*ptr); printf("a=%d\n",a); printf("ptr=%d\n",ptr); printf("&a=%d\n",&a);

6 遞迴範例 #include<iostream> #include<stdio.h> using namespace std; void dec2bin(int a) if(a==1) printf("%d",a); else dec2bin(a/2); printf("%d",a%2);; int a; printf("input an integer a:\n"); scanf("%d",&a); dec2bin(a);

7 OX 遊戲範例 #include<stdio.h> #include<iostream> using namespace std; char output(int); int array[9]=1,2,3,4,5,6,7,8,9; main() int i=0,k=0,x=0; for(k=1;k<=9;k++) printf(" 歡迎測試 tic-tac-toe 小遊戲測試第一版 \n"); printf(" 第 %d",k); printf(" 請輸入 x 座標 :\n"); scanf("%d",&x); if(k%2==1) //1%2=1 2%2=0 3%2=1 array[x-1]=50;// 錯誤 else//1%2=1 2%2=0 3%2=1 array[x-1]=100;// 錯誤 printf(" \n"); //c char 'X' printf(" %c %c %c \n",output(0),output(1),output(2)); printf(" \n"); printf(" %c %c %c \n",output(3),output(4),output(5)); printf(" \n"); printf(" %c %c %c \n",output(6),output(7),output(8)); printf(" \n"); char output(int i)//function 函數函式副程式 // 回傳型態 char 函數名稱 output ( 傳入型態 int 變數 i, 傳入型態 2 變數 2)

8 if(array[i]==50) return 'X'; if(array[i]==100) return 'O'; else return ' ';

9

10 /* prog9_5, 比較陣列元素值的大小 */ #include <stdio.h&rt; #include <stdlib.h&rt; int A[5]=74,48,30,17,62; int i,min,max; min=max=a[0]; /* 將 max 與 min 均設為陣列的第一個元素 */ for(i=0;i<5;i++) if(a[i]&rt;max) /* 判斷 A[i] 是否大於 max */ max=a[i]; if(a[i]<min) /* 判斷 A[i] 是否小於 min */ min=a[i]; printf(" 陣列裡元素的最大值為 %d\n",max); printf(" 陣列裡元素的最小值為 %d\n",min); 取亂數範例 #include <stdio.h> #include <stdlib.h> #include <time.h> int a; srand(time(null)); a=(rand()%9999)+1; printf("the Random Number is %d.\n", a);

11 104-2 程式設計 ( 一 ) 紙筆練習 測驗題 1. 請用另一種表達方式表達相同的下列運算式 (3%) a. temp /=2 b. chu %= 100 c. amount *= cnt1 + cnt2 2. 請用另三種不同方式寫出整數變數 x 減 1 的 C 程式敘述, 如下 : x- - (3%) 3. 請用 C 程式語言敘述完成下列工作 (2%) a. 宣告兩個整數變數 sum 及 x b. 設定變數 x 的值為 1 c. 設定變數 sum 的值為 0 d. 將變數 x 的值加至變數 sum 中, 並將結果指定給變數 sum e. 列印出 The sum is : 及變數 sum 的值 4. 請寫出下列程式之輸出結果 (2%) char symbol[3] = 'a', 'c', 'b'; for (int index = 0; index < 3 ; index++) printf(" %c",symbol[index]); 5. 請寫出下列程式碼的輸出結果 (2%) char a,b,c; a= c ; b= a ; c= b ; printf("%c %c %c c", a, b, c); 6. 請寫出下列程式碼的輸出結果 (4%) int n=2 ; int valueproduced = 3*(++n) - - ; printf( "%d\n",valueproduced) ; printf( "%d\n",n) ; 7. 請完成下列程式輸出結果 (1) 下列程式需輸出由 11 至 1 的整數值 ( 需改寫程式 ) (3%) for (int x=9;x>=1;x - =2) printf( "%d\n",x) ; (2) 輸出 2 至 31 的奇數整數值 ( 需改寫程式 ) (3%) int counter = 2; do printf( "%d\n",counter) ; counter += 2; while (counter <21); (3) 請寫出輸出結果 (3%) int c=1; int product=3; while (c<=5) product *=c; c++; 作答區

12 printf( "%d",product) ; 8. 寫出下列程式輸出結果 (1) int x=1 ; (3%) while (x<=10) x++ ; printf( "%d",x) ; (2) for (double y=.1 ;y!=0.6 ;y+=.1) (3%) printf( "%d\n",y) ; 班級 : 姓名 : (3) int n; (3%) ( 請先輸入一個任意數值, 寫出輸出 ) scanf("%d",&n); switch (1) case 1 : printf( " The number is 1\n") ; break; case 2 : printf( " The number is 2\n") ; break; case 3 : printf( " The number is 1 or 2\n") ; break; 9. (1) 請寫出下列變數值或位址 (10%)( 假設起始位址 0x22ff84) a= b= &a= &b= ptr1= &ptr1= *ptr1= ptr2= &ptr2= *ptr2= (2) 請畫出程式執行到最後的記憶體關係圖 (5%) int a=10,b=8, *ptr1,*ptr2; ptr1=&a; ptr2=&b; *ptr1=17; *ptr2=25; ptr2=ptr1; a=7; *ptr1=2; a=6; *ptr1=*ptr2+*ptr1; *ptr2=*ptr2+*ptr1;

13 10. 請寫出左列程式的輸出結果, 並且說明原因 (8%) int *ptri; double *ptrd; printf("sizeof(ptri)=%d\n", sizeof(ptri)); printf("sizeof(ptrd)=%d\n", sizeof(ptrd)); printf("sizeof(*ptri)=%d\n", sizeof(*ptri)); printf("sizeof(*ptrd)=%d\n", sizeof(*ptrd)); 11. 請寫出以下的輸出結果 (8%) int x; int a[10]=12,11,10,9,8,7,6,5,4,3; int *p; p=&x; x=75; *p=10; p=a+8; printf( " x=%d\n",x) ; printf( "*p=%d\n",*p) ; 12. 以下遞迴程式, 請畫出 n=4 遞迴的過程, 以一個方框代表呼叫一次函式 (15%) int fact(int a) if(a>0) return (a*fact(a-1)); else return 1; int a; do printf("input an integer:\n"); scanf("%d",&a); while(a<=0) printf( 1*2* *%d=%d",a,fact(a) 13. 此圖為一個二維陣列, 請用迴圈語法寫程式印出 3, 5,7 (10%)

14 上機練習 * 請將以前的作業題目進行練習 1. 停車場狀態顯示 (1) 設計 10 個車位, 可輸入停車號碼表示停車, (2) 可重複輸入停車編號, 辨識該號碼是否已停車 (3) 顯示目前剩下車位數, 顯示停車場顯示狀態 2. 將一組 5 個整數陣列數字, 依序從小到大排序好, 原序列是沒排序的數列 3. 請試寫一個遞迴函數 int sum(int n), 會先讓使用者在主程式中輸入一個介於 3~9 的數字 n, 如果超過此範圍會產生錯誤訊息, 若符合 3~9 的數字, 則呼叫 sum(n), 然後 sum() 函數會利用遞迴函數 ( 函數自己呼叫自己的方式 ), 計算出 1*2 + 2 * * * ( n - 1) * n 的結果, 並將結果回傳至 main() 主程式中顯示 4. 把主程式內的陣列 a[6]=0,1,2,3,4,5, 利用指標方式, 在函式內改成 a[6]=0,0,0,0,0,0 5. 讓使用者可以輸入 5 筆學生考試的資料, 每一位學生的輸入資料包括學號 姓名 程設分數 會計分數 計概分數, 輸入完一筆資料後, 可以繼續輸入下一筆, 直到使用者在輸入學號 每一筆輸入資料的格式範例如下, 而此程式需要將使用者輸入的分數資料儲存至以 score 命名的二維陣列變數中 [ 畫面範例 ] 請依照 [ 學號 姓名 程設分數 會計分數 計概分數 ] 順序輸入學生成績 :: B 應小熊 B 王小華 輸入 5 筆資料, 求出平均成績與加總成績 7. 建立一個二維陣列, 5*5 的陣列, 請將 1-25 依序填入, 並印出 5*5 的陣列 8. 用遞迴方式解, 輸入 n, 輸出第 n 個數字 f(1)=1 f(2)=1 f(3)=2 f(n)=f(n-1)+f(n-2)+f(n-3) 9. n! n 階乘輸入 n 輸出 n! 10. a 的 b 次方, 輸入 a,b 輸出 a 的 b 次方 11. 請使用 for 指令設計一程式讓使用者輸入 n, 並呼叫一自訂函數, 印出下面的圖案 ( 下圖為 n=5 時顯示的 n 層圖形 ) 四則運算用函式, 請用字元辨識 13. 試撰寫一支程式 int prime(int n) 可找出第 n 個質數, 質數是指 1 與自己可整除, 請找出第 100 個質數 14. 請你使用 do...while 迴圈指令幫她寫一程式能找出 100~999 中, 有幾組數字, 其三個數字

15 的平方之和正好等於該數減去 100, 即 XYZ = X 平方 + Y 平方 + Z 平方 15. 主程式 main 呼叫 func1 接收 func1 回傳 印出 BMI func1 輸入身高, 體重 計算 BMI 回傳 BMI 回主程式 16. 主程式 main 輸入 a,b,c 呼叫 func1 呼叫 func2 接收 func1 回傳印出 a+b 接收 func2 回傳印出 a*b*c func1 計算 a+b 回傳 a+b 回主程式 func2 計算 a*b*c 回傳 a*b*c 回主程式

Microsoft PowerPoint - C_Structure.ppt

Microsoft PowerPoint - C_Structure.ppt 結構與其他資料型態 Janet Huang 5-1 結構的宣告 struct 結構名稱 struct 結構名稱變數 1, 變數 2,, 變數 m; struct 結構名稱 變數 1, 變數 2,, 變數 m; student; student; 5-2 1 結構變數初值的設定 struct 結構名稱 struct 結構名稱變數 = 初值 1, 初值 2,, 初值 n student="janet","1350901",100,95

More information

Microsoft Word C-A卷.docx

Microsoft Word C-A卷.docx 100 學年度資訊學院程式設計會考 (C) 101/05/5 題組 :A 選擇題及填充題, 請在答案卡上作答, 實作題請填寫於答案卷上, 並於實作題上方填寫班級 姓名 學號 一 選擇題題目 1. unsigned char 的最大值 (a) 127 (b) 255 (c) 512 (d) 1023 2. 下列何者為正確的變數名稱? (a) Android (b) C++ (c) I Phone (d)

More information

第3章.doc

第3章.doc 3 3 3 3.1 3 IT Trend C++ Java SAP Advantech ERPCRM C++ C++ Synopsys C++ NEC C C++PHP C++Java C++Java VIA C++ 3COM C++ SPSS C++ Sybase C++LinuxUNIX Motorola C++ IBM C++Java Oracle Java HP C++ C++ Yahoo

More information

資料結構之C語言重點複習

資料結構之C語言重點複習 鏈結串列自編教材 ( 一 ) 本教材 ( 一 ) 目標問題 : 每次以亂數產生一 [0,1000] 之整數值, 若該值 >100, 則以同方式繼續產生下一亂數值, 若該值

More information

C++ 程式設計

C++ 程式設計 C C 料, 數, - 列 串 理 列 main 數串列 什 pointer) 數, 數, 數 數 省 不 不, 數 (1) 數, 不 數 * 料 * 數 int *int_ptr; char *ch_ptr; float *float_ptr; double *double_ptr; 數 (2) int i=3; int *ptr; ptr=&i; 1000 1012 ptr 數, 數 1004

More information

碩命題橫式

碩命題橫式 一 解釋名詞 :(50%) 1. Two s complement of an integer in binary 2. Arithmetic right shift of a signed integer 3. Pipelining in instruction execution 4. Highest and lowest layers in the TCP/IP protocol suite

More information

C/C++语言 - C/C++数据

C/C++语言 - C/C++数据 C/C++ C/C++ Table of contents 1. 2. 3. 4. char 5. 1 C = 5 (F 32). 9 F C 2 1 // fal2cel. c: Convert Fah temperature to Cel temperature 2 # include < stdio.h> 3 int main ( void ) 4 { 5 float fah, cel ;

More information

<4D F736F F D DA5BFA6A1C476C1C92DBEC7ACECB8D5A8F728B57BB35D292E646F63>

<4D F736F F D DA5BFA6A1C476C1C92DBEC7ACECB8D5A8F728B57BB35D292E646F63> 全國高級中等學校 106 學年度商業類科學生技藝競賽 程式設計 職種 學科 試卷 選手證號碼 ( 崗位編號 ): 姓名 : 注意事項 : 請將答案劃記於答案卡, 未依規定劃記者不予計分 試題說明 :( 選擇題共 25 題每題 4 分, 答錯不倒扣, 共 100 分 ) ( )1. 執行以下 Visual Basic 程式片段, 其結果為何?(A) 15 (B) 12 (C) 7 (D) 3 Dim

More information

Microsoft Word - 投影片ch06

Microsoft Word - 投影片ch06 Java2 JDK5.0 教學手冊第三版洪維恩編著博碩文化出版書號 pg20210 第六章陣列 本章學習目標認識陣列與一般資料型態的不同認識一維與二維陣列學習陣列的應用 陣列 6-2 6.1 一維陣列 一維陣列 (1-dimensional array) 可以存放多個相同資料型態的資料 6.1.1 一維陣列的宣告與記憶體的配置 要使用陣列必須經過兩個步驟 :(1) 宣告陣列 (2) 配置記憶體給該陣列

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: feis.tw@gmail.com 9 [P.11] : Dev C++ [P.12] : http://c.feis.tw [P.13] [P.14] [P.15] [P.17] [P.23] Dev C++ [P.24] [P.27] [P.34] C / C++ [P.35] 10 C / C++ C C++ C C++ C++ C ( ) C++

More information

C C

C C C C 2017 3 8 1. 2. 3. 4. char 5. 2/101 C 1. 3/101 C C = 5 (F 32). 9 F C 4/101 C 1 // fal2cel.c: Convert Fah temperature to Cel temperature 2 #include 3 int main(void) 4 { 5 float fah, cel; 6 printf("please

More information

p-2

p-2 B 卷 選擇題 共 50 題 ( 共 100 分 ) 1. 執行下列 Visual Basic 程式片段後, 共輸出幾筆資 料? x = 0: y = 1 Print y x = x + y Print x y = y + 1 If x >= 10 Then Exit Loop While y

More information

Microsoft Word - ACL chapter02-5ed.docx

Microsoft Word - ACL chapter02-5ed.docx 第 2 章神奇的質數 2.1.1 什麼是質數 1 1 1 打下好基礎 - 程式設計必修的數學思維與邏輯訓練 1 1 0 10 2 3 5 7 4 6 8 9 10 4 10000 1229 1000 168 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 101 103 107 109 113 127 131

More information

C/C++程序设计 - 字符串与格式化输入/输出

C/C++程序设计 - 字符串与格式化输入/输出 C/C++ / Table of contents 1. 2. 3. 4. 1 i # include # include // density of human body : 1. 04 e3 kg / m ^3 # define DENSITY 1. 04 e3 int main ( void ) { float weight, volume ; int

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: feis.tw@gmail.com 49 [P.51] C/C++ [P.52] [P.53] [P.55] (int) [P.57] (float/double) [P.58] printf scanf [P.59] [P.61] ( / ) [P.62] (char) [P.65] : +-*/% [P.67] : = [P.68] : ,

More information

2013 C 1 # include <stdio.h> 2 int main ( void ) 3 { 4 int cases, a, b, i; 5 scanf ("%d", & cases ); 6 for (i = 0;i < cases ;i ++) 7 { 8 scanf ("%d %d

2013 C 1 # include <stdio.h> 2 int main ( void ) 3 { 4 int cases, a, b, i; 5 scanf (%d, & cases ); 6 for (i = 0;i < cases ;i ++) 7 { 8 scanf (%d %d 2013 18 ( ) 1. C pa.c, pb.c, 2. C++ pa.cpp, pb.cpp, Compilation Error cin scanf Time Limit Exceeded 1: A 5 B 5 C 5 D 5 E 5 F 5 1 2013 C 1 # include 2 int main ( void ) 3 { 4 int cases, a, b,

More information

C 語言—陣列及字串

C 語言—陣列及字串 10/16 系程主講人 : 荊輔翔 概論 陣列 陣列是一個具有索引 (index) 性質的連續資料儲存空間集合 陣列中每一個資料儲存空間稱之為陣列元素 (array element); 它們都具有相同的資料名稱 資料型態 及空間大小 ; 但存取它們時則須藉由索引 ( 或稱註標 ) 來區別辨識 索引代表資料在陣列中的相對位址 ( 其計數由 0 開始, 其餘累加類推 ), 且須由中括號 [ ] 涵蓋之

More information

C/C++ - 文件IO

C/C++ - 文件IO C/C++ IO Table of contents 1. 2. 3. 4. 1 C ASCII ASCII ASCII 2 10000 00100111 00010000 31H, 30H, 30H, 30H, 30H 1, 0, 0, 0, 0 ASCII 3 4 5 UNIX ANSI C 5 FILE FILE 6 stdio.h typedef struct { int level ;

More information

C 1

C 1 C homepage: xpzhangme 2018 5 30 C 1 C min(x, y) double C // min c # include # include double min ( double x, double y); int main ( int argc, char * argv []) { double x, y; if( argc!=

More information

C/C++语言 - 运算符、表达式和语句

C/C++语言 - 运算符、表达式和语句 C/C++ Table of contents 1. 2. 3. 4. C C++ 5. 6. 7. 1 i // shoe1.c: # include # define ADJUST 7. 64 # define SCALE 0. 325 int main ( void ) { double shoe, foot ; shoe = 9. 0; foot = SCALE * shoe

More information

C/C++ - 函数

C/C++ - 函数 C/C++ Table of contents 1. 2. 3. & 4. 5. 1 2 3 # include # define SIZE 50 int main ( void ) { float list [ SIZE ]; readlist (list, SIZE ); sort (list, SIZE ); average (list, SIZE ); bargragh

More information

CHAPTER VC#

CHAPTER VC# 1. 2. 3. 4. CHAPTER 2-1 2-2 2-3 2-4 VC# 2-5 2-6 2-7 2-8 Visual C# 2008 2-1 Visual C# 0~100 (-32768~+32767) 2 4 VC# (Overflow) 2-1 2-2 2-1 2-1.1 2-1 1 10 10!(1 10) 2-3 Visual C# 2008 10! 32767 short( )

More information

untitled

untitled 1-1 1-2 1-3 1-4 1-5 1-6 1-7 1-8 1-1-1 C int main(void){ int x,y,z; int sum=0; double avg=0.0; scanf("%d",&x) ; scanf("%d",&y) ; scanf("%d",&z) ; sum=x+y+z ; avg=sum/3.0; printf("%f\n",avg); system("pause");

More information

840 提示 Excel - Excel -- Excel (=) Excel ch0.xlsx H5 =D5+E5+F5+G5 (=) = - Excel 00

840 提示 Excel - Excel -- Excel (=) Excel ch0.xlsx H5 =D5+E5+F5+G5 (=) = - Excel 00 Excel - - Excel - -4-5 840 提示 Excel - Excel -- Excel (=) Excel ch0.xlsx H5 =D5+E5+F5+G5 (=) = - Excel 00 ( 0 ) 智慧標籤 相關說明提示 -5 -- Excel 4 5 6 7 8 + - * / % ^ = < >= & 9 0 (:) (,) ( ) Chapter - :,

More information

新版 明解C言語入門編

新版 明解C言語入門編 328, 4, 110, 189, 103, 11... 318. 274 6 ; 10 ; 5? 48 & & 228! 61!= 42 ^= 66 _ 82 /= 66 /* 3 / 19 ~ 164 OR 53 OR 164 = 66 ( ) 115 ( ) 31 ^ OR 164 [] 89, 241 [] 324 + + 4, 19, 241 + + 22 ++ 67 ++ 73 += 66

More information

C/C++ - 数组与指针

C/C++ - 数组与指针 C/C++ Table of contents 1. 2. 3. 4. 5. 6. 7. 8. 1 float candy [ 365]; char code [12]; int states [50]; 2 int array [6] = {1, 2, 4, 6, 8, 10}; 3 // day_mon1.c: # include # define MONTHS 12 int

More information

Microsoft Word - part doc

Microsoft Word - part doc 3 指標與陣列 3-1 指標與一維陣列 3-2 指標與二維陣列 3-3 陣列指標 3-4 為什麼 parr 等同於 *parr? 3-5 指向陣列的指標 3-6 多重指標 3-7 命令列引數 3-8 除錯題 3-9 問題演練 3-10 程式實作 32 Part 1 C 程式語言篇 指標其實就是一位址 陣列的名稱, 表示此陣列第一個元素的位址, 所以它也是指標 由此可知, 指標與陣列的關係是很密切的

More information

新・明解C言語入門編『索引』

新・明解C言語入門編『索引』 !... 75!=... 48 "... 234 " "... 9, 84, 240 #define... 118, 213 #include... 148 %... 23 %... 23, 24 %%... 23 %d... 4 %f... 29 %ld... 177 %lf... 31 %lu... 177 %o... 196 %p... 262 %s... 242, 244 %u... 177

More information

Python a p p l e b e a r c Fruit Animal a p p l e b e a r c 2-2

Python a p p l e b e a r c Fruit Animal a p p l e b e a r c 2-2 Chapter 02 變數與運算式 2.1 2.1.1 2.1.2 2.1.3 2.1.4 2.2 2.2.1 2.2.2 2.2.3 type 2.2.4 2.3 2.3.1 print 2.3.2 input 2.4 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 + 2.4.6 Python Python 2.1 2.1.1 a p p l e b e a r c 65438790

More information

C/C++ - 字符输入输出和字符确认

C/C++ - 字符输入输出和字符确认 C/C++ Table of contents 1. 2. getchar() putchar() 3. (Buffer) 4. 5. 6. 7. 8. 1 2 3 1 // pseudo code 2 read a character 3 while there is more input 4 increment character count 5 if a line has been read,

More information

<4D F736F F D B0D3B77EC3FEA7DEC3C0C476C1C9A5BFA6A1B8D5C3442DB57BA6A1B35DAD702DBEC7ACEC2E646F6378>

<4D F736F F D B0D3B77EC3FEA7DEC3C0C476C1C9A5BFA6A1B8D5C3442DB57BA6A1B35DAD702DBEC7ACEC2E646F6378> 全國國高級中中等學校 105 學年度商商業類學學生技藝藝競賽 程式式設計 職職種 學學科 試試卷 崗位位編號 : 姓名 : 注意事項 : 請將答案案劃記於答案案卡, 未依依規定劃記者者不予計分分 試題說明 :( 選擇題每每題 4 分, 共 100 分 ) ( )1. 執行以下 Visual Basic 程式片段, 其結果為何?(A) 15 Dim i As Byte i = &HFC Console.WriteLine(Not

More information

chap07.key

chap07.key #include void two(); void three(); int main() printf("i'm in main.\n"); two(); return 0; void two() printf("i'm in two.\n"); three(); void three() printf("i'm in three.\n"); void, int 标识符逗号分隔,

More information

untitled

untitled Introduction to Programming ( 數 ) Lecture 3 Spring 2005 March 4, 2005 Lecture 2 Outline 數 料 If if 狀 if 2 (Standard Output, stdout): 料. ((Standard Input, stdin): 料. 類 數 數 數 說 printf 見 數 puts 串 數 putchar

More information

新・解きながら学ぶC言語

新・解きながら学ぶC言語 330!... 67!=... 42 "... 215 " "... 6, 77, 222 #define... 114, 194 #include... 145 %... 21 %... 21 %%... 21 %f... 26 %ld... 162 %lf... 26 %lu... 162 %o... 180 %p... 248 %s... 223, 224 %u... 162 %x... 180

More information

2015年计算机二级(C语言)模拟试题及答案(四)

2015年计算机二级(C语言)模拟试题及答案(四) 2016 年 计 算 机 二 级 (C 语 言 ) 模 拟 试 题 及 答 案 (4) 一 填 空 题 1 C 语 言 中 基 本 的 数 据 类 型 有 : 2 C 语 言 中 普 通 整 型 变 量 的 类 型 说 明 符 为, 在 内 存 中 占 字 节, 有 符 号 普 通 整 型 的 数 据 范 围 是 3 整 数 -35 在 机 内 的 补 码 表 示 为 4 执 行 下 列 语 句 int

More information

6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C C C51 C51 ANSI C MCS-51 C51 ANSI C C C51 bit Byte bit sbit

6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C C C51 C51 ANSI C MCS-51 C51 ANSI C C C51 bit Byte bit sbit 6 C51 ANSI C Turbo C C51 Turbo C C51 C51 C51 C51 C51 C51 C51 C51 C51 6.1 C51 6.1.1 C51 C51 ANSI C MCS-51 C51 ANSI C C51 6.1 6.1 C51 bit Byte bit sbit 1 0 1 unsigned char 8 1 0 255 Signed char 8 11 128

More information

Microsoft PowerPoint - STU_C_Lang_CH13.ppt

Microsoft PowerPoint - STU_C_Lang_CH13.ppt 第 13 章 動態配置記憶體 程式設計與生活 - 使用 C 語言 Shi-Huang Chen Spring 2013 第 13 章 動態配置記憶體 13-1 記憶體配置函式 malloc( ) 13-2 動態配置結構陣列 配置記憶體 預估需求數量的範圍是一項不容易的學問 例 : 大到預估今年國家預算, 小到預估櫥窗裡展示的毛線衣, 需要多少磅毛線才能織成 撰寫程式時, 一樣無法預估程式執行所需的記憶體空間

More information

untitled

untitled 1 1.1 1.2 1.3 1.4 1.5 ++ 1.6 ++ 2 BNF 3 4 5 6 7 8 1.2 9 1.2 IF ELSE 10 1.2 11 1.2 12 1.3 Ada, Modula-2 Simula Smalltalk-80 C++, Objected Pascal(Delphi), Java, C#, VB.NET C++: C OOPL Java: C++ OOPL C# C++

More information

C 1 # include <stdio.h> 2 int main ( void ) { 4 int cases, i; 5 long long a, b; 6 scanf ("%d", & cases ); 7 for (i = 0;i < cases ;i ++) 8 { 9

C 1 # include <stdio.h> 2 int main ( void ) { 4 int cases, i; 5 long long a, b; 6 scanf (%d, & cases ); 7 for (i = 0;i < cases ;i ++) 8 { 9 201 201 21 ( ) 1. C pa.c, pb.c, 2. C++ pa.cpp, pb.cpp Compilation Error long long cin scanf Time Limit Exceeded 1: A 1 B 1 C 5 D RPG 10 E 10 F 1 G II 1 1 201 201 C 1 # include 2 int main ( void

More information

Microsoft Word - C-pgm-ws2010.doc

Microsoft Word - C-pgm-ws2010.doc Information and Communication Technology 資訊與通訊科技 Loops (while/for) C 廻路 姓名 : 班別 : ( ) CS C Programming #1 Functions 函數 : 1 若 n=14, 求以下表示式的值 Expressions 表示式 Value 值 Expressions 表示式 Value 值 A 20 2 * (n /

More information

C++ 程序设计 告别 OJ1 - 参考答案 MASTER 2019 年 5 月 3 日 1

C++ 程序设计 告别 OJ1 - 参考答案 MASTER 2019 年 5 月 3 日 1 C++ 程序设计 告别 OJ1 - 参考答案 MASTER 2019 年 月 3 日 1 1 INPUTOUTPUT 1 InputOutput 题目描述 用 cin 输入你的姓名 ( 没有空格 ) 和年龄 ( 整数 ), 并用 cout 输出 输入输出符合以下范例 输入 master 999 输出 I am master, 999 years old. 注意 "," 后面有一个空格,"." 结束,

More information

C

C C 2017 3 14 1. 2. 3. 4. 2/95 C 1. 3/95 C I 1 // talkback.c: 2 #include 3 #include 4 #define DENSITY 62.4 5 int main(void) 6 { 7 float weight, volume; 8 int size; 9 unsigned long letters;

More information

國立北斗家商 107 學年度第 2 學期第二次期中考科目 : 計算機應用 計算機概論 IV 班級 : 商二 1 2 貿二 資二 綜二 1 作答方式 : 答案卡 選擇題共 33 題, 除第 1 題 4 分, 其餘每題 3 分, 注意作答時間 1. ( ) 使用 Visual Basic 程式語言 (

國立北斗家商 107 學年度第 2 學期第二次期中考科目 : 計算機應用 計算機概論 IV 班級 : 商二 1 2 貿二 資二 綜二 1 作答方式 : 答案卡 選擇題共 33 題, 除第 1 題 4 分, 其餘每題 3 分, 注意作答時間 1. ( ) 使用 Visual Basic 程式語言 ( 國立北斗家商 107 學年度第 2 學期第二次期中考科目 : 計算機應用 計算機概論 IV 班級 : 商二 1 2 貿二 資二 綜二 1 作答方式 : 答案卡 選擇題共 33 題, 除第 1 題 4 分, 其餘每題 3 分, 注意作答時間 1. ( ) 使用 Visual Basic 程式語言 ( 以下皆是 ) 執行下列程式碼後,T 值為何? (A)495 (B)550 (C)594 (D)5050

More information

1

1 基本練習題 1 答 :(A) 2 答 :(B) 3 答 :(C) 4 答 :(B) 5 答 :(D) 6 答 :2 7 答 :(B) 8 答 : (A) A B C / D E * + F G / - (B) A B + C D - * E / (C) A B C * + E F + - 9 答 : (A) - + A * - / BCDE / F G (B) / * + A B C D E (C)

More information

Excel VBA Excel Visual Basic for Application

Excel VBA  Excel Visual Basic for Application Excel VBA Jun5,00 Sub 分頁 () Dim i As Integer Dim Cname As String Dim Code As Variant Set score=thisworkbook.sheets("sheet") Code=Array(" 專北一 "," 專北二 "," 專北三 "," 專桃園 "," 專桃竹 "," 專中苗 ", " 專台中 "," 專台南 ","

More information

Microsoft PowerPoint - Class5.pptx

Microsoft PowerPoint - Class5.pptx C++ 程式初探 V 2015 暑期 ver. 1.0.1 C++ 程式語言 大綱 1. 大量檔案讀取 & 計算 2. 指標 3. 動態記憶體 & 動態陣列 4. 標準函式庫 (STL) vector, algorithm 5. 結構與類別 2 大量檔案讀取 & 計算 若目前有一個程式將讀取純文字文件 (.txt) 中的整數, 並將該文件中的整數有小到大排序後, 儲存到另外一個新的純文字件中 假設有

More information

2013 C 1 #include <stdio.h> 2 int main(void) 3 { 4 int cases, i; 5 long long a, b; 6 scanf("%d", &cases); 7 for (i = 0; i < cases; i++) 8 { 9 scanf("%

2013 C 1 #include <stdio.h> 2 int main(void) 3 { 4 int cases, i; 5 long long a, b; 6 scanf(%d, &cases); 7 for (i = 0; i < cases; i++) 8 { 9 scanf(% 2013 ( 28 ) ( ) 1. C pa.c, pb.c, 2. C++ pa.cpp, pb.cpp Compilation Error long long cin scanf Time Limit Exceeded 1: A 10 B 1 C 1 D 5 E 5 F 1 G II 5 H 30 1 2013 C 1 #include 2 int main(void) 3

More information

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc 2 5 8 11 0 13 1. 13 2. 15 3. 18 1 23 1. 23 2. 26 3. 28 2 36 1. 36 2. 39 3. 42 4. 44 5. 49 6. 51 3 57 1. 57 2. 60 3. 64 4. 66 5. 70 6. 75 7. 83 8. 85 9. 88 10. 98 11. 103 12. 108 13. 112 4 115 1. 115 2.

More information

c_cpp

c_cpp C C++ C C++ C++ (object oriented) C C++.cpp C C++ C C++ : for (int i=0;i

More information

没有幻灯片标题

没有幻灯片标题 指针作为函数参数 : 原因 : 1 需要修改一个或多个值,( 用 return 语句不能解决问题 ) 2 执行效率的角度 使用方法 : 在函数原型以及函数首部中需要声明能够接受指针值的形参, 具体的写法为 : 数据类型 * 形参名 如果有多个指针型形参, 则用逗号分隔, 例如 : void swap(int *p1, int *p2) 它说明了形参 p1 p2 是指向整型变量的指针 在函数调用时,

More information

C/C++ - 字符串与字符串函数

C/C++ - 字符串与字符串函数 C/C++ Table of contents 1. 2. 3. 4. 1 char C 2 char greeting [50] = " How " " are " " you?"; char greeting [50] = " How are you?"; 3 printf ("\" Ready, go!\" exclaimed John."); " Ready, go!" exclaimed

More information

C

C C 14 2017 5 31 1. 2. 3. 4. 5. 2/101 C 1. ( ) 4/101 C C ASCII ASCII ASCII 5/101 C 10000 00100111 00010000 ASCII 10000 31H 30H 30H 30H 30H 1 0 0 0 0 0 ASCII 6/101 C 7/101 C ( ) ( ) 8/101 C UNIX ANSI C 9/101

More information

untitled

untitled 1 2 3 4 5 6 2005 30 28 36 29 19 33 6 58 1 1 2. 3 1 2 4 5 6 7 8 58 2 30 30 1 01 58 3 2 1 2 3 1 2 3 4 5 58 4 6 7 8 1 9 10 11 12 13 14 15 16 17 18 19 20 1 ( 1 ) 21 22 23 24 25 26 58 5 27 28 29 30 31 32 33

More information

C/C++ 语言 - 循环

C/C++ 语言 - 循环 C/C++ Table of contents 7. 1. 2. while 3. 4. 5. for 6. 8. (do while) 9. 10. (nested loop) 11. 12. 13. 1 // summing.c: # include int main ( void ) { long num ; long sum = 0L; int status ; printf

More information

C

C C 2017 4 1 1. 2. while 3. 4. 5. for 6. 2/161 C 7. 8. (do while) 9. 10. (nested loop) 11. 12. 3/161 C 1. I 1 // summing.c: 2 #include 3 int main(void) 4 { 5 long num; 6 long sum = 0L; 7 int status;

More information

1

1 守大學電機系 電腦視覺 報告 單元一 數位影像 : 格式和操作 參考解答 MIAT( 機器智慧與自動化技術 ) 實驗室 中華民國 93 年 9 月 29 日 1. (a) 如果指紋影像 finger300x300 的取像面積是 14(mm)x14(mm), 請計算取像系統的 dpi (b) 如果 kaoshiung512x512 遙測影像的覆蓋面積是 5(Km)x5(Km), 請計算該影像的解析度

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: feis.tw@gmail.com 177 [P179] (1) - [P181] [P182] (2) - for [P183] (3) - switch [P184] [P187] [P189] [P194] 178 [ ]; : : int var; : int var[3]; var 2293620 var[0] var[1] 2293620

More information

第 15 章遞迴呼叫 本章學習目標 說明遞迴函式呼叫概念 透過範例介紹遞迴函式呼叫與應用 本章重點概述 本章主要介紹如何使用遞迴函式呼叫進行計算 1

第 15 章遞迴呼叫 本章學習目標 說明遞迴函式呼叫概念 透過範例介紹遞迴函式呼叫與應用 本章重點概述 本章主要介紹如何使用遞迴函式呼叫進行計算 1 第 15 章遞迴呼叫 本章學習目標 說明遞迴函式呼叫概念 透過範例介紹遞迴函式呼叫與應用 本章重點概述 本章主要介紹如何使用遞迴函式呼叫進行計算 1 15.1 何謂遞迴函式 遞迴就是函數自己呼叫自己 如果一個問題的解決可以拆成多個相同的小問題, 這 樣的問題就很適合使用 以 階層數 計算的問題為例, 若階層數的函式為 fac(n) = n (n-1) (n-2) 1, 如果不使用遞迴呼叫時我們可以把式子寫成下列形式,

More information

!249 第 八講 進階指標 講師 : 李根逸 (Ken-Yi Lee),

!249 第 八講 進階指標 講師 : 李根逸 (Ken-Yi Lee), 249 第 八講 進階指標 講師 : 李根逸 (Ken-Yi Lee), E-mail: feis.tw@gmail.com 250 課程 大綱 陣列的複製 [P.252] 字串的特殊性 [P.255] const 修飾字 [P.256] 指標陣列 [P.257] 字串陣列 [P.258] 指標與 二維陣列 [P.260] 動態記憶體配置與釋放 C 語 言中動態記憶體的配置 [P.266] C 語

More information

untitled

untitled CHAPTER 02 2 CHAPTER 2-1 2-4 2-2 2-5 2-3 2-6 2-1 2-1-1 2-2 02 int A[3] = {10, 20, 30; A[0] 10 A[1] 20 A[2] 30 int *pa[3], A[3]; C 3 pa pa[0]pa[1]pa[2] 3 A A[0]A[1]A[2] 3 A A[0] A + i A[i] A + i &A[i]*(A

More information

untitled

untitled A, 3+A printf( ABCDEF ) 3+ printf( ABCDEF ) 2.1 C++ main main main) * ( ) ( ) [ ].* ->* ()[] [][] ** *& char (f)(int); ( ) (f) (f) f (int) f int char f char f(int) (f) char (*f)(int); (*f) (int) (

More information

C/C++语言 - 分支结构

C/C++语言 - 分支结构 C/C++ Table of contents 1. if 2. if else 3. 4. 5. 6. continue break 7. switch 1 if if i // colddays.c: # include int main ( void ) { const int FREEZING = 0; float temperature ; int cold_ days

More information

02

02 Thinking in C++: Volume One: Introduction to Standard C++, Second Edition & Volume Two: Practical Programming C++ C C++ C++ 3 3 C C class C++ C++ C++ C++ string vector 2.1 interpreter compiler 2.1.1 BASIC

More information

新・解きながら学ぶJava

新・解きながら学ぶJava 481! 41, 74!= 40, 270 " 4 % 23, 25 %% 121 %c 425 %d 121 %o 121 %x 121 & 199 && 48 ' 81, 425 ( ) 14, 17 ( ) 128 ( ) 183 * 23 */ 3, 390 ++ 79 ++ 80 += 93 + 22 + 23 + 279 + 14 + 124 + 7, 148, 16 -- 79 --

More information

( CIP) /. :, ( ) ISBN TP CIP ( 2005) : : : : * : : 174 ( A ) : : ( 023) : ( 023)

( CIP) /. :, ( ) ISBN TP CIP ( 2005) : : : : * : : 174 ( A ) : : ( 023) : ( 023) ( CIP) /. :, 2005. 2 ( ) ISBN 7-5624-3339-9.......... TP311. 1 CIP ( 2005) 011794 : : : : * : : 174 ( A ) :400030 : ( 023) 65102378 65105781 : ( 023) 65103686 65105565 : http: / /www. cqup. com. cn : fxk@cqup.

More information

プログラムの設計と実現II

プログラムの設計と実現II UNIX C ls mkdir man http://www.tj.chiba-u.jp/lecture/prog2/ Ctrl+x, Ctrl+s ( )..[4]% gcc Wall o hoge hoge.c..[5]%./hoge 1 : 1 2 : 2 3 : 3 4 : 0 6..[6]% (! )..[4]% gcc Wall o hoge hoge.c..[5]%!g gcc Wall

More information

NOWOER.OM m/n m/=n m/n m%=n m%n m%=n m%n m/=n 4. enum string x1, x2, x3=10, x4, x5, x; 函数外部问 x 等于什么? 随机值 5. unsigned char *p1; unsigned long *p

NOWOER.OM m/n m/=n m/n m%=n m%n m%=n m%n m/=n 4. enum string x1, x2, x3=10, x4, x5, x; 函数外部问 x 等于什么? 随机值 5. unsigned char *p1; unsigned long *p NOWOER.OM /++ 程师能 评估. 单项选择题 1. 下 描述正确的是 int *p1 = new int[10]; int *p2 = new int[10](); p1 和 p2 申请的空间 的值都是随机值 p1 和 p2 申请的空间 的值都已经初始化 p1 申请的空间 的值是随机值,p2 申请的空间 的值已经初始化 p1 申请的空间 的值已经初始化,p2 申请的空间 的值是随机值 2.

More information

C/C++ - 结构体、共用体、枚举体

C/C++ - 结构体、共用体、枚举体 C/C++ Table of contents 1. 2. 3. 4. 5. 6. 7. 8. 1 C C (struct) C 2 C C (struct) C 2 i // book.c: # include < stdio.h> # define MAX_ TITLE 41 # define MAX_ AUTHOR 31 struct book { char title [ MAX_ TITLE

More information

C++ 程序设计 告别 OJ2 - 参考答案 MASTER 2019 年 5 月 3 日 1

C++ 程序设计 告别 OJ2 - 参考答案 MASTER 2019 年 5 月 3 日 1 C++ 程序设计 告别 OJ2 - 参考答案 MASTER 2019 年 5 月 3 日 1 1 TEMPLATE 1 Template 描述 使用模板函数求最大值 使用如下 main 函数对程序进行测试 int main() { double a, b; cin >> a >> b; cout c >> d; cout

More information

Microsoft Word - F7801B_ch04習題解答.doc

Microsoft Word - F7801B_ch04習題解答.doc 基本練習題 1. 要將中序式轉成後序式, 需要用到何種資料結構? (A) 堆疊 (B) 佇列 (C) 堆積 (D) B 樹答 :(A) 2. 下列何者不是堆疊的應用場合?(A) 運算式轉換 (B) 工作排程 (C) 副程式的呼叫與返回 (D) 後序式的求值答 :(B) 3. 一個原來為空的堆疊, 經過 Push(1),Push(2),Pop(),Push(3),Pop(),Push(4) 則 堆疊中的資料由上而下順序是

More information

Microsoft PowerPoint - 06_迴圈2.pptx

Microsoft PowerPoint - 06_迴圈2.pptx 資料型別的選擇 如果資料或是運算過程可能會出現小數點 (e.g. BMI), 宜使用浮點數 (double, float) char 僅能儲存一個英文字 數字 或是英文中出現的標點符號等等鍵盤上可直接看得到 按得出的符號 若要儲存中文字, 目前建議使用 string 型別 A 和 A 的差別, 我們目前還沒辦法說得很詳細 只能說一個是字元 一個是字串 布林運算式的寫法 如果 x 等於, 就印出 Hello

More information

untitled

untitled 1 Outline 數 料 數 數 列 亂數 練 數 數 數 來 數 數 來 數 料 利 料 來 數 A-Z a-z _ () 不 數 0-9 數 不 數 SCHOOL School school 數 讀 school_name schoolname 易 不 C# my name 7_eleven B&Q new C# (1) public protected private params override

More information

Generated by Unregistered Batch DOC TO PDF Converter , please register! 浙江大学 C 程序设计及实验 试题卷 学年春季学期考试时间 : 2003 年 6 月 20 日上午 8:3

Generated by Unregistered Batch DOC TO PDF Converter , please register! 浙江大学 C 程序设计及实验 试题卷 学年春季学期考试时间 : 2003 年 6 月 20 日上午 8:3 浙江大学 C 程序设计及实验 试题卷 2002-2003 学年春季学期考试时间 : 2003 年 6 月 20 日上午 8:30-10:30 注意 : 答题内容必须写在答题卷上, 写在本试题卷上无效 一. 单项选择题 ( 每题 1 分, 共 10 分 ) 1. 下列运算符中, 优先级最低的是 A.

More information

Spyder Anaconda Spyder Python Spyder Python Spyder Spyder Spyder 開始 \ 所有程式 \ Anaconda3 (64-bit) \ Spyder Spyder IPython Python IPython Sp

Spyder Anaconda Spyder Python Spyder Python Spyder Spyder Spyder 開始 \ 所有程式 \ Anaconda3 (64-bit) \ Spyder Spyder IPython Python IPython Sp 01 1.6 Spyder Anaconda Spyder Python Spyder Python Spyder Spyder 1.6.1 Spyder 開始 \ 所有程式 \ Anaconda3 (64-bit) \ Spyder Spyder IPython Python IPython Spyder Python File

More information

Microsoft PowerPoint - 13_指標、資料傳遞2.pptx

Microsoft PowerPoint - 13_指標、資料傳遞2.pptx 1 2 指標 Lecture 13 指標函式呼叫的資料傳遞 (III) 傳址指標與陣列 Pointer 3 4 指標 / 指位器 (Pointer) 變數 int a; 整數型別, 名稱為 a 變數是為了使用記憶體資源來儲存資料與進行運算 所有的變數都佔有記憶體空間 記憶體 可視為一個很大的一維陣列, 單位是 byte 問題 一個 4KB 的電腦, 其記憶體位置 ( 編號 ) 從 0 至? 4 x

More information

Microsoft PowerPoint - Class4.pptx

Microsoft PowerPoint - Class4.pptx C++ 程式初探 IV 2015 暑期 ver. 1.0.2 C++ 程式 IV 大綱 1. 時間函式 2. 格式化輸出 3. 遞迴函式 (recursion) 4. 字串 5. 字串轉型 2 補充語法 時間計算 引入標頭檔 #include #include #include #include using namespace

More information

2. S 輸入一個整數 n, 求出從 1 ~ n 所有可以被 3 整除及又可以被 7 整除所有 的數字的總和的程式 ( 請上傳 Sum_3_7.py 檔 ) Sum_3_7.py 程式樣版 n = int(input()

2. S 輸入一個整數 n, 求出從 1 ~ n 所有可以被 3 整除及又可以被 7 整除所有 的數字的總和的程式 ( 請上傳 Sum_3_7.py 檔 ) Sum_3_7.py 程式樣版 n = int(input() 朝陽資管系進修部 python 程式檢定題庫 1. S 請試撰寫一程式, 讓使用者傳入一數值 A, 判斷此數是否為 2 或 3 的倍數, 如是印出 true, 否則印 false ( 請上傳 Multiple.py 檔 ) 0 true 184 true 84 true 78 true 91 false Multiple.py 程式樣板 A = int(input()) 2. S 輸入一個整數 n,

More information

Microsoft Word - Chap05.doc

Microsoft Word - Chap05.doc 迴圈敘述 5-1 for 迴圈 5-2 while 迴圈 5-3 do...while 迴圈 5-4 巢狀迴圈 5-5 break 與 continue 5-6 ++ 附加於條件運算式 5-7 迴圈的應用範例 5-8 關鍵字 5-9 問題演練 5-10 程式實作 5-2 迴圈敘述 (loop statement) 的功能就是可以重複執行敘述 迴圈敘述主要有 for while 和 do...while

More information

105A 資管一程式設計實驗 06 函式定義謝明哲老師 2 程式設計實驗 6.3: 自行定義一個可以接受兩個整數並傳回其最大公因數的函式, 接著利用該函式自 行定義一個可以接受兩個整數並傳回其最小公倍數函式 // gcd_fcn.cpp int gcd(int m,

105A 資管一程式設計實驗 06 函式定義謝明哲老師 2 程式設計實驗 6.3: 自行定義一個可以接受兩個整數並傳回其最大公因數的函式, 接著利用該函式自 行定義一個可以接受兩個整數並傳回其最小公倍數函式 // gcd_fcn.cpp int gcd(int m, 105A 資管一程式設計實驗 06 函式定義謝明哲老師 hmz@nttu.edu.tw 1 程式設計實驗 06 函式定義 模擬問題 03 在模擬問題 02, 小組已完成擬定一個與學習或日常生活有關的問題, 並依據在 Ch5 所 學到的流程控制與檔案存取技術發展小組的第二版個別化資訊服務程式 現在請小組對第二版程式的 結構進行分析, 檢查是否有哪些功能可以使用在 Ch6 所學到的函式定義來加以模組化,

More information

The golden pins of the PCI card can be oxidized after months or years

The golden pins of the PCI card can be oxidized after months or years Q. 如何在 LabWindows/CVI 編譯 DAQ Card 程式? A: 請參考至下列步驟 : 步驟 1: 安裝驅動程式 1. 安裝 UniDAQ 驅動程式 UniDAQ 驅動程式下載位置 : CD:\NAPDOS\PCI\UniDAQ\DLL\Driver\ ftp://ftp.icpdas.com/pub/cd/iocard/pci/napdos/pci/unidaq/dll/driver/

More information

Microsoft PowerPoint - Class2.pptx

Microsoft PowerPoint - Class2.pptx C++ 程式初探 II 2015 暑期 C++ 程式 II 大綱 1. 變數 2. 運算式 3. 輸出 4. 條件判斷 5. 迴圈 6. 陣列 2 基本變數型態 整數 位元組 浮點數 位元組 字元 位元組 short 2 float 4 char ( 整數 ) 1 int 2 (4) double 8 long 4 (8) long double 8(10) 位元組 整數値域 浮點數値域 準確度 1-128

More information

int *p int a 0x00C7 0x00C7 0x00C int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++;

int *p int a 0x00C7 0x00C7 0x00C int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++; Memory & Pointer trio@seu.edu.cn 2.1 2.1.1 1 int *p int a 0x00C7 0x00C7 0x00C7 2.1.2 2 int I[2], *pi = &I[0]; pi++; char C[2], *pc = &C[0]; pc++; float F[2], *pf = &F[0]; pf++; 2.1.3 1. 2. 3. 3 int A,

More information

新版 明解C++入門編

新版 明解C++入門編 511!... 43, 85!=... 42 "... 118 " "... 337 " "... 8, 290 #... 71 #... 413 #define... 128, 236, 413 #endif... 412 #ifndef... 412 #if... 412 #include... 6, 337 #undef... 413 %... 23, 27 %=... 97 &... 243,

More information

投影片 1

投影片 1 資料庫管理程式 ( 補充教材 -Part2) 使用 ADO.NET 連結資料庫 ( 自行撰寫程式碼 以實現新增 刪除 修改等功能 ) Private Sub InsertButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InsertButton.Click ' 宣告相關的 Connection

More information

nooog

nooog C : : : , C C,,, C, C,, C ( ), ( ) C,,, ;,, ; C,,, ;, ;, ;, ;,,,, ;,,, ; : 1 9, 2 3, 4, 5, 6 10 11, 7 8, 12 13,,,,, 2008 1 1 (1 ) 1.1 (1 ) 1.1.1 ( ) 1.1.2 ( ) 1.1.3 ( ) 1.1.4 ( ) 1.1.5 ( ) 1.2 ( ) 1.2.1

More information

C/C++基礎程式設計班

C/C++基礎程式設計班 C/C++ 基礎程式設計 指標 (Pointer) 講師 : 張傑帆 CSIE, NTU 瘋到自以為能改變世界的人, 就能改變世界 The people who are crazy enough to think they can change the world are the ones who do.-steve Jobs 課程大綱 指標簡介 陣列與指標 動態記憶體配置 指標宣告進階 指標 用途

More information

C语言的应用.PDF

C语言的应用.PDF AVR C 9 1 AVR C IAR C, *.HEX, C,,! C, > 9.1 AVR C MCU,, AVR?! IAR AVR / IAR 32 ALU 1KBytes - 8MBytes (SPM ) 16 MBytes C C *var1, *var2; *var1++ = *--var2; AVR C 9 2 LD R16,-X ST Z+,R16 Auto (local

More information

Microsoft Word - CPE考生使用手冊160524.docx

Microsoft Word - CPE考生使用手冊160524.docx 大 學 程 式 能 力 檢 定 (CPE) 考 生 使 用 手 冊 2016 年 5 月 24 日 這 份 手 冊 提 供 給 參 加 CPE 檢 定 考 試 的 考 生 內 容 包 含 考 試 環 境 的 使 用, 以 及 解 題 時 所 使 用 I/O 的 基 本 知 識 1. 如 欲 報 名 參 加 CPE 考 試, 請 先 於 CPE 網 站 完 成 帳 號 註 冊, 然 後 再 報 名 該

More information

0 0 = 1 0 = 0 1 = = 1 1 = 0 0 = 1

0 0 = 1 0 = 0 1 = = 1 1 = 0 0 = 1 0 0 = 1 0 = 0 1 = 0 1 1 = 1 1 = 0 0 = 1 : = {0, 1} : 3 (,, ) = + (,, ) = + + (, ) = + (,,, ) = ( + )( + ) + ( + )( + ) + = + = = + + = + = ( + ) + = + ( + ) () = () ( + ) = + + = ( + )( + ) + = = + 0

More information

Java 程式設計初階 第 5 章:基本輸出入 & 流程控制

Java 程式設計初階 第 5 章:基本輸出入 & 流程控制 Java 程式設計 標準輸出入與流程控制 本章大綱 標準輸出入 (Standard I/O) 分支 (Branch) if ~ else switch ~ case 迴圈 (Loop) for while do ~ while 中斷指令 break continue 總整理 標準輸出 定義 : 將資料印到螢幕上 Java 標準輸出指令 System.out.println( 資料 ) 將資料印出後換行

More information

FY.DOC

FY.DOC 高 职 高 专 21 世 纪 规 划 教 材 C++ 程 序 设 计 邓 振 杰 主 编 贾 振 华 孟 庆 敏 副 主 编 人 民 邮 电 出 版 社 内 容 提 要 本 书 系 统 地 介 绍 C++ 语 言 的 基 本 概 念 基 本 语 法 和 编 程 方 法, 深 入 浅 出 地 讲 述 C++ 语 言 面 向 对 象 的 重 要 特 征 : 类 和 对 象 抽 象 封 装 继 承 等 主

More information

運算子多載 Operator Overloading

運算子多載 Operator Overloading 函數樣板 (Function Template) 與 類別樣板 (Class Template) 講師 : 洪安 1 資料結構與 C++ 程式設計進階班 為何需要通用函數? (1/2) int abs(int x) { return (x>0)?x:-x; 取名困難不好記 float fabs(float x) { return (x>0)?x:-x; complex cabs(complex x)

More information

PowerPoint 簡報

PowerPoint 簡報 本周未安排實作輔導 預定 : 下周六 迴圈 LOOP 應用 判斷質數 (Prime number) 求兩個整數的最大公因數 (greatest common divisor, GCD) 判斷迴文 (palindrome) 搶答!! Q1 : 印出結果? int s,x; s=0; for(x=1;x

More information

extend

extend (object oriented) Encapsulation Inheritance Polymorphism Dynamic Binding (base class) (derived class) 1 class Base { int I; void X(); void Y(); class Derived: public Base { private: int j; void z(); Derived

More information

Microsoft Word - 第3章.doc

Microsoft Word - 第3章.doc Java C++ Pascal C# C# if if if for while do while foreach while do while C# 3.1.1 ; 3-1 ischeck Test() While ischeck while static bool ischeck = true; public static void Test() while (ischeck) ; ischeck

More information

epub 33-8

epub 33-8 8 1) 2) 3) A S C I I 4 C I / O I / 8.1 8.1.1 1. ANSI C F I L E s t d i o. h typedef struct i n t _ f d ; i n t _ c l e f t ; i n t _ m o d e ; c h a r *_ n e x t ; char *_buff; /* /* /* /* /* 1 5 4 C FILE

More information

Microsoft PowerPoint - 04-array_pointer.ppt

Microsoft PowerPoint - 04-array_pointer.ppt Array 與 Pointer Array Dynamical Memory Allocation Array( 陣列 ) 陣列是用來存放同樣型態的資料陣列的大小必須在程式中預先設定在程式執行中, 陣列的大小無法改變陣列中的資料是透過索引 (index) 來存取 一維陣列的宣告 type array_name[array_size]; int iarray[100]; /* an integer array

More information

上海市本科教学质量年度报告

上海市本科教学质量年度报告 上 海 市 本 科 教 学 质 量 年 度 报 告 数 据 内 涵 说 明 V2.0 版 上 海 市 教 委 高 教 处 上 海 喆 思 (2015.07.02) 目 录 一 基 本 统 计 挃 标 说 明... 4 二 挃 标 解 释... 4 1. 全 日 制 在 校 本 科 生 数 及 占 在 校 生 总 数 的 比 例 ( 学 年 )... 4 2. 当 年 本 科 招 生 与 业 总 数

More information

Microsoft PowerPoint - C_Language_flag4e_ch08.ppt [相容模式]

Microsoft PowerPoint - C_Language_flag4e_ch08.ppt [相容模式] 第八章 函數 認識函數與其原型 學習函數的宣告方式與定義 認識區域 全域與靜態變數 學習前置處理器的用法 1 8.1 簡單的函數範例 C 語言的函數 Top-down design 的目的是要達到逐步單純化 將大問題細分成小問題 將解決這些小問題的方法, 撰寫成較小的程式區塊 C 語言的函數 如賦予程式區塊一個名字 並且指定它的輸出與輸入 則此程式區塊就是一個 C 語言的函數 2 8.1 簡單的函數範例

More information