程式设计简介ppt课件



《程式设计简介ppt课件》由会员分享,可在线阅读,更多相关《程式设计简介ppt课件(44页珍藏版)》请在装配图网上搜索。
1、按一下以編輯母片標題樣式,按一下以編輯母片,2002,程式設計簡介,李俊宏,2006/11/03,程式設計簡介李俊宏,1,何謂程式與程式設計,程式,控制電腦如何做動作的指令集合,程式設計,設計一組指令集合控制電腦做動作,何謂程式與程式設計程式控制電腦如何做動作的指令集合程式設計設,何謂電腦系統以及為何要作程式設計,作業系統,使用者,使用者,使用者,程式設計師,程式編譯軟體,組合語言編譯軟體,文字編輯軟體,資料庫系統軟體,電腦硬體,電腦軟體,Office,軟體,黃易群俠傳遊戲軟體,系統軟體,何謂電腦系統以及為何要作程式設計作業系統使用者使用者使用者程,由硬體觀點看程式設計,計算邏輯單元,控制單元
2、,暫存器,主記憶體,輸入,輸出,硬碟控制器,外接硬體界面,CPU,電腦程式,由硬體觀點看程式設計計算邏輯單元控制單元暫存器主記憶體輸入輸,程式語言,程式,c+之間的關係為何,程式,控制電腦如何做動作的指令集合,程式語言,寫指令集合時須符合的格式,C+,語言,一種程式語言,程式語言,程式,c+之間的關係為何程式控制電腦如何做動,機器語言,組合語言,與高階語言,三種程式語言,(,依與硬體相關性分類,),機器語言,控制機器的特定數字字串,-,人類很難看懂,例子,:,+1300042774,+1400593419,+1200274027,組合語言,比較像文字的控制機器的指令,須組譯器轉成機器可以看懂的
3、機器語言,例子,:,LOAD BASEPAY,ADD OVERPAY,STORE GROSSPAY,高階語言,更像文字,(,英文,),的控制機器的指令,用數學符號來表示運算式,例子,grossPay=basePay+overTimePay,1,/*Fig.2.1:fig02_01.c,2,A first program in C*/,3,#include,4,5,int,main(),6,7,printf(Welcome to C!n);,8,9,return,0;,10,機器語言,組合語言,與高階語言三種程式語言(依與硬體相關,基礎的程式發展環境,基礎的程式發展步驟,編輯,前置處理,編譯,連
4、結,載入,執行,編輯程式,處理程式的前置碼,載入主記憶體,CPU,按順序一個一個執行被轉成機器語言的程式碼,編譯程式轉成機器語言並存到儲存裝置,連結外部的函式庫,(,別人寫好的,),載入器,主記憶體,編譯器,編輯器,前置處理器,連結器,主記憶體,.,.,.,.,.,.,.,.,.,.,.,.,Disk,Disk,磁碟,CPU,Disk,Disk,IDE(,整合開發環境,),基礎的程式發展環境基礎的程式發展步驟編輯程式處理程式的前,程式的整體觀點,電腦系統,使用者,其他系統,Control,Interface,Data,硬體觀點,輸出入裝置,CPU,儲存裝置,視窗畫面,程式執行的控制,資料結構,
5、軟體觀點,程式的整體觀點電腦系統使用者其他系統ControlInter,程式例子,1,/*Fig.2.1:fig02_01.c,2,A first program in C+*/,3,#include,4,4using std:cout;,5,int,main(),6,7,cout=1),column=1;,while(column=10),printf(%s,row%2?);,+column;,-row;,printf(n);,return 0;,資料,控制流程,動作,三大程式基本要素#include 資料控制,資料:Variable(變 數),#include main(),int a,b
6、;,a=1;,b=a+2;,printf(The value of,1+2 is%i.,b);,0,31,a,b,?,?,0000 0000 0000 0001,0000 0000 0000 0011,The value of 1+2 is 3.,電腦記憶體,RAM,資料:Variable(變 數)#include=60)printf(Passedn);,true,false,grade=60,print“Passed”,The if Selection StructurePseu,The,if,/,else,Selection Structure,C code:,if(grade=60),p
7、rintf(Passedn);,else,printf(Failedn);,true,false,print“Failed”,print“Passed”,grade=60,The if/else Selection Structur,The,while,Repetition Structure,Example:,int product=2;,while(product=1000)product=2*product;,product=1000,product=2*product,true,false,The while Repetition Structure,The for Repetitio
8、n Structure,格式,for(,初值,;,狀況測試,;,增加,),要重覆的內容,Example:,for(int counter=1;counter=10;counter+),printf(%dn,counter);,印出整數,1-10,No semicolon(,;,)after last expression,counter=10,printf(%dn,counter),true,false,int counter=1,The for Repetition Structure格式,The,switch,Multiple-Selection Structure,格式,switch(v
9、alue),case 1:,動作,break;,case 2:,動作,break;,default:,動作,break;,break;,離開的點,The switch Multiple-Selection,switch,多重選擇結構,Flowchart of the,switch,structure,true,false,.,.,.,case a,case a action(s),break,case b,case b action(s),break,false,false,case z,case z action(s),break,true,true,default action(s),sw
10、itch 多重選擇結構Flowchart of the,do,/,while,重覆結構,Example(counter=1):,do,printf(%d ,counter);,while(+counter max),24,max=y;,25,26,if,(z max),27,max=z;,28,29,return,max;,30,Function prototype(3 parameters),2.Input values,2.1 Call function,Function definition,1/*Fig.5.4:fig05_04.c2,Functions,Functions,Modul
11、arize a program,All variables declared inside functions are local variables,Known only in function defined,Parameters,Communicate information between functions,Local variables,Benefits of functions,Divide and conquer,Manageable program development,Software reusability,Use existing functions as build
12、ing blocks for new programs,Abstraction-hide internal details(library functions),Avoid code repetition,FunctionsFunctions,Function Definitions,Function definition format(continued),return-value-type function-name(parameter-list),declarations and statements,Declarations and statements:function body(b
13、lock),Variables can be declared inside blocks(can be nested),Functions can not be defined inside other functions,Returning control,If nothing returned,return;,or,until reaches right brace,If something returned,return,expression,;,Function DefinitionsFunction d,Function Prototypes,Function prototype,
14、Function name,Parameters what the function takes in,Return type,data type function returns(default,int,),Used to validate functions,Prototype only needed if function definition comes after use in program,The function with the prototype,int maximum(int,int,int);,Takes in 3,int,s,Returns an,int,Promot
15、ion rules and conversions,Converting to lower types can lead to errors,Function PrototypesFunction pr,Header Files,Header files,Contain function prototypes for library functions,etc,Load with,#include,#include,Custom header files,Create file with functions,Save as,filename.h,Load in other files with,#include filename.h,Reuse functions,Header FilesHeader files,
- 温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。