SlideShare a Scribd company logo
1 of 44
程式設計入門
第一講
臺北市立大學/資訊科學所
吳彥儒
課程介紹
電腦X程式語言
Karel project
JAVA foundation
課程目標
 對程式語言有基本的認識
 具備基本的程式設計能力
 覺得寫程式是一件有趣的事
評量方式
出席 10%
課堂表現 30%
平時作業 30%
期中報告 30%
參考書目
• 上課投影片
• Java How to program: Early objects
version 9/e
Author: Deitel
• Introduction to Java Programming,
Comprehensive version 9th edition
Author: Y.Daniel Liang
怎麼沒有中文書?
Q:各位對電腦的認識程度?
其他?
計算機的演進
第一部電腦由 Atanasoff 和 Berry 於1930年在愛荷華州立大學建造
目的是為了要幫助研究做原子物理的數學運算
第一部大型的電子數位電腦為ENIAC於1946年在賓州大學由美軍投
資建造
重30噸,佔 30 X 50 呎的空間,用在天氣預測和原子能的計算
超大型積體電路時期VLSI
西元1971年INTEL 4004發表,為微處理機之開始
(為當今CPU之祖先)
之後推出8080,8086,8286,80386以及Pentium系列
早期的主記憶體為磁蕊 magnetic core memory
8 bytes vs. 8Gbytes
電腦系統的構成
• 硬體 (Hardware)
1. 中央處理單元 CPU
2. 記憶體 main memory
3. 輔助記憶體 storage devices
4. 通訊裝置 communication devices
5. 輸入裝置 input devices
6. 輸出裝置 output devices
• 軟體 (Software)
程式 Program-能使電腦執行特殊任務的一串指令
BUS
Storage Memory CPU
Communi
cation
Input Output
Disk, CD, Tape NIC Keyboard,
Mouse
Printer
Figure. 電腦的組成
中央處理單元
Central processing unit, CPU
協調所有的電腦動作並執行資料的算術與邏輯運算
CPU處理儲存在main memory裡的程式,循序取出
指
令並解讀指令,讀出該指令所需要的資料。
處理完後,會將執行的結果儲存回main memory。
主記憶體
大部分有兩種主記憶體:
• RAM(random access memory)暫存程式與資料
當電腦關機RAM的內容會消失 (揮發性記憶體)
• ROM(read-only memory)可永久性的儲存資料與程
式
記憶體的結構
-27
354
x
ADD
75.62
.
.
.
SUB
88
0
1
2
3
4
.
.
.
998
999
位址 內容
可視為一塊有序的儲存位置,
稱為記憶格(Memory cell)。
為了存取資料,電腦必須能
辨識單一的記憶格,因此每
個記憶格都會有唯一的位址
(address)。
內容可以是程式
指令或資料
一個很重要的觀念
那就是任何的程式指令在被執行前必
須先載入主記憶體中
這就是所謂的程式儲存觀念
主記憶體儲存單位
Bit & Byte
• 位元(bit)名稱得自二進位數字,是電
腦能處理的最小元素
• 二進位(Binary)是以0, 1為符號的數字
系統
• 一個位元組(Byte)由八個為位元(bit)構
成
• 記憶格所採的單位為Byte,至於每一格
的Byte數目則因電腦而異
儲存容量的名詞
名詞 縮寫 相當於 與10的次方比較
Byte B 8 bits
Kilobyte KB 1,024(210)Byte >103
Megabyte MB 1,048,576(220)Byte >106
Gigabyte GB 1,073,741,824(230)Byte >109
Terabyte TB 1,099,511,627,776(240)Byte >1012
關於資料表示法
資料在電腦內部的表示方法和人類用的不相同
前面提到,在電腦內部所使用的是二進位的表示法
故,要教大家如何在不同的進制之間做轉換
(十六進制與二進制)
數字系統中數值的表示法
假設 A 這個數值採用の是 X 進制則表示法為:Ax 或 A(x)
Example: 10010011(2) 356(10)
符號在數字所擺放的位置決定了它表示的值
±( Pk-1…P2P1P0 . P-1P-2…P-l )X
其值:
n= ± Pk-1* xk-1 +…+P1* x1 +P0* x0+P-1* x-1 + P-2* x-2 + …+ P-
l* x-l
位置數目系統
X是基底
(base)
數字系統中數值的表示法
假設 A 這個數值採用の是 X 進制則表示法為:Ax 或 A(x)
Example: 10010011(2) 356(10)
以上面の例子來看
3*102+5*101+6*100 = 356
1*27+1*24+1*21+1*20 = 147
Example: 24.13(10)
= 2*101 + 4*100 + 1*10-1 + 3*10-2
十六進制
表示符號:0 1 2 3 4 5 6 7 8 9 A B C D E
F
與十進制對應 A=10 B=11 C=12 … F=15
BAD(16)
= B*162+A*161+D*160=2989
Example: 2AE(16)
= 2*101 + 4*100 + 1*10-1 + 3*10-2
請問下列哪一種表示法是錯誤的:
(a)234.5(10)
(b)234.5(5)
(c)1101.1101(2)
(d)456.7(8)
ANS : (b)
數字系統的轉換
將數值分成整數部分與小數部分個別處理
整數用短除法
做法:
將整數部分除以X進制,每次除完的商數為下一次除
法運算的被除數,而餘數將成為結果的一部份,反
覆執行上述步驟直到商為零才結束
小數用乘法
做法:
將小數的部分乘以X進制,乘法運算完後的小數為下
一次乘法運算的被乘數,而結果值由每次乘法運算
的整數部分所構成,反覆執行上述動作直到小數為
零或計算到題目所規定的位數時為止
Example: 34.25(10) 轉成對應的二進制
2
2
2
2
2
2
34
17
8
4
2
1
0
......0
......1
......0
......0
......0
......1
結果由下往上取
小數部分0.25
第一次乘法:0.25*2= 0.5
第二次乘法:0.5*2=1
因為小數的部分為零,即滿足終止條件
對應到二進為的小數第一位為0,第二位為1
答案:34.25(10)=100010.01(2)
承上題轉成相對應的十六進制
34
2
16
16
0
…… 2
…… 2
結果由下往上取
小數部分
0.25*16 = 4
因為小數的部分為零,即滿足終止條件
答案:34.25(10)= 22.4(16)
練習:
(1)11101011.1011(2)= ?(10)
(2)1A.23(16)= ? (10)
(3)1A.23(16)= ? (2)
ANS: (1) 235.6875 (2) 26.137 (3) 11010.00100011
程式是什麼 ?
為什麼要寫程式?
嘿 等等!
剛剛不是說電腦只懂0,1
那我們寫程式不就是寫成
10101100
11001011
事實上當然不是這樣
電腦看得懂的,我們稱作機器語言(machine language)
缺點就是沒有標準,不同的CPU會有不同的機器語言
另外同樣是低階語言的組合語言(assembly language)亦
有
相同的問題
所以,我們在寫程式時一般都會用所謂的高階程式語言
(high-level language)
高階語言是由一些英文符號和代數算數式所構成
看下敘述:
a = a + b;
這段敘述的意思是說將變數a與變數b的和,存回至變數a
不同應用領域
TIOBE Index for July 2014
但是電腦看不懂高階語言
那怎麼辦?
這時侯需要有個翻譯的角色
編譯器(Compiler):
將高階語言轉成機器語言的程式
輸入,轉換及執行高階語言程式
文字編
輯器
編譯器
連結器
載入器
原始檔
格式:文字
目的檔
格式:二進位
執行檔
格式:二進位
其他目的檔
格式:二進位
PC
錯誤訊息
輸入 結果
失
敗
成功
.obj
.exe
文字編輯器:可以用像是 Notepad++ sublime text
真的都沒有,還可以用記事本
連結器(linker):結合目的檔並解決交叉參考,產生可執
行的機器語言的程式
載入器(loader):將程式載入至記憶體,並指示CPU開始
執行工作
最後課堂作業
請大家加入Facebook 課程群組
和平高中X 程式設計入門
並且用簡短的方式自我介紹一下
本週課程就到這
咱們下週見Bye~

More Related Content

Recently uploaded

哪里可以购买日本筑波学院大学学位记/做个假的文凭可认证吗/仿制日本大学毕业证/意大利语CELI证书定制
哪里可以购买日本筑波学院大学学位记/做个假的文凭可认证吗/仿制日本大学毕业证/意大利语CELI证书定制哪里可以购买日本筑波学院大学学位记/做个假的文凭可认证吗/仿制日本大学毕业证/意大利语CELI证书定制
哪里可以购买日本筑波学院大学学位记/做个假的文凭可认证吗/仿制日本大学毕业证/意大利语CELI证书定制jakepaige317
 
泽兰应用科学大学毕业证制作/定制国外大学录取通知书/购买一个假的建国科技大学硕士学位证书
泽兰应用科学大学毕业证制作/定制国外大学录取通知书/购买一个假的建国科技大学硕士学位证书泽兰应用科学大学毕业证制作/定制国外大学录取通知书/购买一个假的建国科技大学硕士学位证书
泽兰应用科学大学毕业证制作/定制国外大学录取通知书/购买一个假的建国科技大学硕士学位证书jakepaige317
 
EDUC6506_ClassPresentation_TC330277 (1).pptx
EDUC6506_ClassPresentation_TC330277 (1).pptxEDUC6506_ClassPresentation_TC330277 (1).pptx
EDUC6506_ClassPresentation_TC330277 (1).pptxmekosin001123
 
educ6506presentationtc3302771-240427173057-06a46de5.pptx
educ6506presentationtc3302771-240427173057-06a46de5.pptxeduc6506presentationtc3302771-240427173057-06a46de5.pptx
educ6506presentationtc3302771-240427173057-06a46de5.pptxmekosin001123
 
EDUC6506(001)_ClassPresentation_2_TC330277 (1).pptx
EDUC6506(001)_ClassPresentation_2_TC330277 (1).pptxEDUC6506(001)_ClassPresentation_2_TC330277 (1).pptx
EDUC6506(001)_ClassPresentation_2_TC330277 (1).pptxmekosin001123
 
1.🎉“入侵大学入学考试中心修改成绩”来袭!ALEVEL替考大揭秘,轻松搞定考试成绩! 💥你还在为无法进入大学招生系统而烦恼吗?想知道如何通过技术手段更改...
1.🎉“入侵大学入学考试中心修改成绩”来袭!ALEVEL替考大揭秘,轻松搞定考试成绩! 💥你还在为无法进入大学招生系统而烦恼吗?想知道如何通过技术手段更改...1.🎉“入侵大学入学考试中心修改成绩”来袭!ALEVEL替考大揭秘,轻松搞定考试成绩! 💥你还在为无法进入大学招生系统而烦恼吗?想知道如何通过技术手段更改...
1.🎉“入侵大学入学考试中心修改成绩”来袭!ALEVEL替考大揭秘,轻松搞定考试成绩! 💥你还在为无法进入大学招生系统而烦恼吗?想知道如何通过技术手段更改...黑客 接单【TG/微信qoqoqdqd】
 

Recently uploaded (6)

哪里可以购买日本筑波学院大学学位记/做个假的文凭可认证吗/仿制日本大学毕业证/意大利语CELI证书定制
哪里可以购买日本筑波学院大学学位记/做个假的文凭可认证吗/仿制日本大学毕业证/意大利语CELI证书定制哪里可以购买日本筑波学院大学学位记/做个假的文凭可认证吗/仿制日本大学毕业证/意大利语CELI证书定制
哪里可以购买日本筑波学院大学学位记/做个假的文凭可认证吗/仿制日本大学毕业证/意大利语CELI证书定制
 
泽兰应用科学大学毕业证制作/定制国外大学录取通知书/购买一个假的建国科技大学硕士学位证书
泽兰应用科学大学毕业证制作/定制国外大学录取通知书/购买一个假的建国科技大学硕士学位证书泽兰应用科学大学毕业证制作/定制国外大学录取通知书/购买一个假的建国科技大学硕士学位证书
泽兰应用科学大学毕业证制作/定制国外大学录取通知书/购买一个假的建国科技大学硕士学位证书
 
EDUC6506_ClassPresentation_TC330277 (1).pptx
EDUC6506_ClassPresentation_TC330277 (1).pptxEDUC6506_ClassPresentation_TC330277 (1).pptx
EDUC6506_ClassPresentation_TC330277 (1).pptx
 
educ6506presentationtc3302771-240427173057-06a46de5.pptx
educ6506presentationtc3302771-240427173057-06a46de5.pptxeduc6506presentationtc3302771-240427173057-06a46de5.pptx
educ6506presentationtc3302771-240427173057-06a46de5.pptx
 
EDUC6506(001)_ClassPresentation_2_TC330277 (1).pptx
EDUC6506(001)_ClassPresentation_2_TC330277 (1).pptxEDUC6506(001)_ClassPresentation_2_TC330277 (1).pptx
EDUC6506(001)_ClassPresentation_2_TC330277 (1).pptx
 
1.🎉“入侵大学入学考试中心修改成绩”来袭!ALEVEL替考大揭秘,轻松搞定考试成绩! 💥你还在为无法进入大学招生系统而烦恼吗?想知道如何通过技术手段更改...
1.🎉“入侵大学入学考试中心修改成绩”来袭!ALEVEL替考大揭秘,轻松搞定考试成绩! 💥你还在为无法进入大学招生系统而烦恼吗?想知道如何通过技术手段更改...1.🎉“入侵大学入学考试中心修改成绩”来袭!ALEVEL替考大揭秘,轻松搞定考试成绩! 💥你还在为无法进入大学招生系统而烦恼吗?想知道如何通过技术手段更改...
1.🎉“入侵大学入学考试中心修改成绩”来袭!ALEVEL替考大揭秘,轻松搞定考试成绩! 💥你还在为无法进入大学招生系统而烦恼吗?想知道如何通过技术手段更改...
 

Featured

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 

Featured (20)

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 

程式設計入門1

Editor's Notes

  1. 對計算機粗淺的介紹
  2. 約42坪大
  3. N進制由N個符號來表示ex:10進制 表示的符號為 0~9, 逢十則進一位
  4. 目的檔:含有機器語言指令的檔案