• 沒有找到結果。

計算機程式

N/A
N/A
Protected

Academic year: 2021

Share "計算機程式"

Copied!
21
0
0

加載中.... (立即查看全文)

全文

(1)

計算機程式

第一單元 Introduction to Computers, the Internet and the WWW

授課教師:廖婉君教授

【 本 著 作 除 另 有 註 明 外 , 採 取 創用 CC

「姓名標示-非商業性-相同方式分享」台灣 3.0

(2)

本課程指定教材

書名: C++ How to Program, 7/e

作者: Harvey M. Deitel and Paul J. Deitel 出版社: Deitel & Associates

出版日期: 2010

(3)

Computer:At A Glance (1/3)

• Hardware

o Central Procesing Unit (CPU) o Arithmetic and Logic Unit (ALU) o Main Memory

o Secondary Storage Unit o Input unit

o Output unit

o Network Interface

(4)

Computer:At A Glance (2/3)

• Software

o System software

• e.g.,Operating System (OS) o Application software

• e.g.,Powerpoint,MS Word,Sky pe

o Programming language

• Machine language

• Assembly language

• High-level language

(5)

Computer:At A Glance (3/3)

• Evolution of Computing/computer

o Main frame

o Personal computer o Networked computer

o Thin client and clout computing o Personal computing

o Distributed computing o Client/Server computing o Peer-to-peer computing

(6)

Basics of a Typical C++ Environment

• C++ system

o Program development environment o Language itself

o C++ standard libraray:

• Classes and functions

• Software IC

• Six phases

o Edit,preprocess,compile,link,load,execute o .cpp,.cxx,.cc,.c

o xx.cpp,#something,CC xx.cpp,a.out

(7)

Six Phases in Program Execution

(8)

C++ Program Structure

• Single-line comment line: //

• Preprocessor directives: # something

o e.g., #include

• Main body

o Classes and functions

o Must come/start with a function called main(),which is delimited by {}.

o Mostly come with I/O

(9)

A skeleton Outline of a Simple C++ Program

• //

• #include <iostream>

• int main (){

o return 0;

• }

preprocessor directive

program goes here!

(10)

Examples (1/2)

p.40

(11)

Examples (2/2)

p.44-45

(12)

Escape Characters

escape

sequence description

\n Newline. Position the screen cursor to the beginning of the next line.

\t Horizontal tab. Move the screen cursor to the next tab stop.

\r Carriage return. Position the screen cursor to the beginning of the current line; do not advance to the next line.

\a Alert. Sound the system bell.

\\ Backslash. Used to print a backslash character

\’ Single quote. Use to print a single quote character.

\” Double quote. Used to print a double quote character.

(13)

Another Example

p. 45

(14)

Another Example (cont.)

p. 46-49

(15)

C++ Keywords

C++ Keywords

Keywords common to the C and C++ programming languages

auto break case char const continue dafault

do double else enum extern float for

goto if int long register return short

signed sizeof static struct switch typedef union

unsigned void volatile while

C++ only keywords

and and_eq asm bitand bitor bool catch

class compl const_cast delete dynamic_cast explicit

export false friend inline mutable namespace

new not not_eq operator or or_eq private

protected public reinterpret_cast static_cast template this

(16)

Built–in Data Types

bool

char

short int

unsigned short int

int

unsigned int

long int

unsigned long int

float

double

long double

bool

char

short int vs . unsigned short int

int vs. unsigned int

long int vs. unsigned long int

float

double

long double

(17)

Variables

• Memory concept

• Declaration

o date type variable name o e.g., int a;

• Variables have characteristics

o name,type,size ,and vale

o case sensitive: e.g.,CAT,Cat,cat o declared before used (anywhere) o legal identifier

• I/O: destructive vs. non-destr uctive

(18)

More on Operators

Operators Associativity Type

() left to right parentheses

* / % left to right multiplicative

+ - left to right additive

<< >> left to right stream insertion/extraction

< <= > >= left to right relational

== != left to right equality

= right to left assignment

associability

(19)

One More Example

p. 55-56

(20)

版權聲明

頁碼 作品 版權圖示 來源 / 作者

1-21 本作品轉載自 Microsoft Office 2007 多媒體藝廊,依據 Microsoft 服務合約及著作權法第

46、 52 、 65 條合理使用。

2

C++ How to Program, 7/e,作者: Harvey M. Deitel and Paul J. Deitel , 出版社: Deitel & Associates ,出版日期: 2010 。

本作品轉載自:

http://www.deitel.com/Books/C/CHowtoProgram7e/tabid/3472/Default.aspx,

依據著作權法第 46 、 52 、 65 條合理使用。

3

Open Clip Art Library,作者: kattekrab ,本作品轉載自:

http://openclipart.org/detail/20928/computer-workstation-by-kattekrab,

瀏覽日期: 2013/1/10 。

4 Open Clip Art Library,作者: sheikh_tuhin ,本作品轉載自:

http://openclipart.org/detail/78217/it-word-icon-by-sheikh_tuhin,瀏覽日期: 2013/1/10 。 4

Wikipedia,作者: Microsoft Corporation ,本作品轉載自:

http://en.wikipedia.org/wiki/File:Skype_logo.svg,瀏覽日期: 2013/1/10 。 依據著作權法第 46 、 52 、 65 條合理使用。

5 Open Clip Art Library,作者: lmproulx ,本作品轉載自:

http://openclipart.org/detail/3982/computer-by-lmproulx,瀏覽日期: 2013/1/10 。

(21)

版權聲明

頁碼 作品 版權圖示 來源 / 作者

7

Faculty Web Sites, Typical Java Development Environment(

http://faculty.inverhills.mnscu.edu/speng/cs1126/Notes/Chapter01/JavaDE.htm),瀏 覽日期: 2012/9/14 。依據著作權法第 46 、 52 、 65 條合理使用。

10、 11 、 13、 14 、

19

Open Clip Art Library,作者: aritztg ,本作品轉載自:

http://openclipart.org/detail/3422/mouse-by-aritztg,瀏覽日期: 2013/1/10 。

12

C++ How to Program, 7/e,作者: Harvey M. Deitel and Paul J. Deitel , 出版社: Deitel & Associates ,出版日期: 2010 , P.41 。

依據著作權法第 46 、 52 、 65 條合理使用。

15 臺灣大學電機系 廖婉君教授

18

C++ How to Program, 7/e,作者: Harvey M. Deitel and Paul J. Deitel , 出版社: Deitel & Associates ,出版日期: 2010 , P.49 。

依據著作權法第 46 、 52 、 65 條合理使用。

參考文獻

相關文件

 To write to the screen (or read the screen), use the next 8K words of the memory To read which key is currently pressed, use the next word of the

command tells Vim to run the text through a UNIX command.The ‘a tells the editor that the text to be worked on starts at the current line and ends at mark a.. The command that

2.1.1 The pre-primary educator must have specialised knowledge about the characteristics of child development before they can be responsive to the needs of children, set

Reading Task 6: Genre Structure and Language Features. • Now let’s look at how language features (e.g. sentence patterns) are connected to the structure

 Promote project learning, mathematical modeling, and problem-based learning to strengthen the ability to integrate and apply knowledge and skills, and make. calculated

Enrich the poem with a line that appeals to this missing sense.. __________________imagery that appeals to the sense of____________has not been used in the description

Now, nearly all of the current flows through wire S since it has a much lower resistance than the light bulb. The light bulb does not glow because the current flowing through it

refined generic skills, values education, information literacy, Language across the Curriculum (