Visual C++ introduction Auditor : Yu-Che Lin Adviser : Prof. Jian-Jiun Ding

Download Report

Transcript Visual C++ introduction Auditor : Yu-Che Lin Adviser : Prof. Jian-Jiun Ding

Visual C++ introduction
Auditor : Yu-Che Lin
Adviser : Prof. Jian-Jiun Ding
Nov. 8 2007
Digital image and signal processing Lab.
Institute of Communication Engineering, National Taiwan University
Taipei, Taiwan, R.O.C.
1
main 函數 ; header 檔
•
•
•
•
傳回值型態 main (引入參數)
{
…..
return 傳回值;
• }
Digital image and signal processing Lab.
Institute of Communication Engineering, National Taiwan University
Taipei, Taiwan, R.O.C.
2
變數宣告
•
•
•
•
int x(=數字);
float y(=數字);
double w(=數字);
char z(=‘字元’);
Digital image and signal processing Lab.
Institute of Communication Engineering, National Taiwan University
Taipei, Taiwan, R.O.C.
3
字串
• char s[7] ; // 宣告變數S含有7個位元長度
• Char s[7] = “Hello!”;
– 結束位元 : \0
Digital image and signal processing Lab.
Institute of Communication Engineering, National Taiwan University
Taipei, Taiwan, R.O.C.
4
算數運算子;比較運算子;邏輯運算子
• 算數運算子:(1)
• +,-,*,/,%
– 算數指定運算子: (由右到左)
• += , -= , *= , /=
– Ex:
int A=2 , B = 5 ; B += A *= 3;
 A = 6 , B = 11
• 比較運算子:(2)
• == , > , < , >= , <= , !=
• 邏輯運算子:(3)
• &&(優先) , || , !
Digital image and signal processing Lab.
Institute of Communication Engineering, National Taiwan University
Taipei, Taiwan, R.O.C.
5
i++ / ++i
Digital image and signal processing Lab.
Institute of Communication Engineering, National Taiwan University
Taipei, Taiwan, R.O.C.
6
for 迴圈
• for (initial value ; condition ; counting)
• {
Statements;
• }
– ex:
• int i,sum=0;
for (i=0; i<=100; i++){
sum = sum + i;
}
Digital image and signal processing Lab.
Institute of Communication Engineering, National Taiwan University
Taipei, Taiwan, R.O.C.
7
Digital image and signal processing Lab.
Institute of Communication Engineering, National Taiwan University
Taipei, Taiwan, R.O.C.
8
Digital image and signal processing Lab.
Institute of Communication Engineering, National Taiwan University
Taipei, Taiwan, R.O.C.
9
if..else if / switch..case
• if (condition1){
switch(condition factor){
Statements;
}
else if (condition2){
case condition1:
Statements;
break;
Statements;
}
…..
else{
case condition2:
Statements;
break;
Statements;
}
…..
default:
statements;
Digital image and signal processing Lab.
Institute of Communication Engineering, National Taiwan University
Taipei, Taiwan, R.O.C.
}
10