程式设计简介课件

上传人:痛*** 文档编号:243981583 上传时间:2024-10-01 格式:PPT 页数:44 大小:223.29KB
返回 下载 相关 举报
程式设计简介课件_第1页
第1页 / 共44页
程式设计简介课件_第2页
第2页 / 共44页
程式设计简介课件_第3页
第3页 / 共44页
点击查看更多>>
资源描述
按一下以編輯母片標題樣式,按一下以編輯母片,2002,程式設計簡介,李俊宏,2006/11/03,程式設計簡介李俊宏,何謂程式與程式設計,程式,控制電腦如何做動作的指令集合,程式設計,設計一組指令集合控制電腦做動作,何謂程式與程式設計程式控制電腦如何做動作的指令集合程式設計設,何謂電腦系統以及為何要作程式設計,作業系統,使用者,使用者,使用者,程式設計師,程式編譯軟體,組合語言編譯軟體,文字編輯軟體,資料庫系統軟體,電腦硬體,電腦軟體,Office,軟體,黃易群俠傳遊戲軟體,系統軟體,何謂電腦系統以及為何要作程式設計作業系統使用者使用者使用者程,由硬體觀點看程式設計,計算邏輯單元,控制單元,暫存器,主記憶體,輸入,輸出,硬碟控制器,外接硬體界面,CPU,電腦程式,由硬體觀點看程式設計計算邏輯單元控制單元暫存器主記憶體輸入輸,程式語言,程式,c+之間的關係為何,程式,控制電腦如何做動作的指令集合,程式語言,寫指令集合時須符合的格式,C+,語言,一種程式語言,程式語言,程式,c+之間的關係為何程式控制電腦如何做動,機器語言,組合語言,與高階語言,三種程式語言,(,依與硬體相關性分類,),機器語言,控制機器的特定數字字串,-,人類很難看懂,例子,:,+1300042774,+1400593419,+1200274027,組合語言,比較像文字的控制機器的指令,須組譯器轉成機器可以看懂的機器語言,例子,:,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,機器語言,組合語言,與高階語言三種程式語言(依與硬體相關,基礎的程式發展環境,基礎的程式發展步驟,編輯,前置處理,編譯,連結,載入,執行,編輯程式,處理程式的前置碼,載入主記憶體,CPU,按順序一個一個執行被轉成機器語言的程式碼,編譯程式轉成機器語言並存到儲存裝置,連結外部的函式庫,(,別人寫好的,),載入器,主記憶體,編譯器,編輯器,前置處理器,連結器,主記憶體,.,.,.,.,.,.,.,.,.,.,.,.,Disk,Disk,磁碟,CPU,Disk,Disk,IDE(,整合開發環境,),基礎的程式發展環境基礎的程式發展步驟編輯程式處理程式的前,程式的整體觀點,電腦系統,使用者,其他系統,Control,Interface,Data,硬體觀點,輸出入裝置,CPU,儲存裝置,視窗畫面,程式執行的控制,資料結構,軟體觀點,程式的整體觀點電腦系統使用者其他系統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;,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),printf(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 Repetition 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(value),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),switch 多重選擇結構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,Modularize 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 building 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(block),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,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,Promotion 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,
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 管理文书 > 施工组织


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!