高级编程语言课件_第1页
高级编程语言课件_第2页
高级编程语言课件_第3页
高级编程语言课件_第4页
高级编程语言课件_第5页
已阅读5页,还剩104页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

高级编程语言Compilers(编译器)Compiler

Aprogramthattranslatesahigh-levellanguageprogramintomachinecodeHigh-levellanguagesprovidearichersetofinstructionsthatmakestheprogrammer’slifeeveneasierthanworkinginassemblylanguage.Aslongasacompilerforthehigh-levellanguageiswrittenforaspecificcomputer,programswritteninthehigh-levellanguagewillrunonthatcomputer.Wesaythatahigh-levellanguageismachine-independent.Machinelanguageandassemblylanguagearemachine-dependent.Compilers(编译过程)Figure8.1CompilationprocessInterpreters(解释器)InterpreterAtranslatingprogramthattranslatesandexecutesthestatementsinsequenceAnassemblerorcompilerproducesmachinecodeasoutputandthatoutputisthenexecutedinaseparatestepAninterpretertranslatesastatementandthenimmediatelyexecutesthestatementInterpreterscanbeviewedassimulators

JavaIntroducedin1996Portability(i.e.machine-independence)wasofprimaryimportanceJavaiscompiledintoastandardizedmachinelanguagecalledBytecodeAsoftwareinterpretercalledtheJVM(JavaVirtualMachine)takestheBytecodeprogramandexecutesitProgrammingLanguageParadigmsFigure8.2

PortabilityprovidedbystandardizedlanguagesversusinterpretationbyBytecodeProgrammingLanguageParadigmsFigure8.2

PortabilityprovidedbystandardizedlanguagesversusinterpretationbyBytecodeFourProgrammingLanguageParadigmsImperativeorproceduralmodelFORTRAN,COBOL,BASIC,C,Pascal,

Ada,andC++FunctionalmodelLISP,Scheme(aderivativeofLISP),andMLLogicprogrammingmodelPROLOGObject-orientedmodelSIMULAandSmalltalkC++isasanimperativelanguagewithsomeobject-orientedfeaturesJavaisanobject-orientedlanguagewithsomeimperativefeaturesFunctionalityofImperativeLanguagesImperativelanguagestypicallyusethefollowingtypesofinstructions:SequencingExecutestatementsinsequenceuntilaninstructionisencounteredthatchangesthissequencing

SelectionDecidewhichactiontotakeIteration(looping)Repeatanaction BothselectionanditerationrequiretheuseofaBooleanexpressionAnIntroductiontotheImperativeFeaturesofJava

Many,butnotall,high-levellanguageshaveimperativefeatures.Javaisobject-orientedalso,butwewilldelaydiscussingthatpartofthelanguageinitially.First,wewillconcentrateontheimperativefeaturesthatJavashareswithC++.Almostalloftheearlyhigh-levellanguageswereimperativelanguages.StructureofJavaProgram//Prologuecomment–whattheprogramdoes//WrittenbyJ.Q.Programmer,10/20/01publicclassName{//classnamestartswithacapitalletterpublicstaticvoidmain(String[]args){

statement1;//Semicolonseparatesstatements

statement2;//Programbody

….

}//endofmethodmain'sdefinition}//endoftheclassdefinitionVariableVariableAlocationinmemorythatcontainsadatavalueandisreferencedbyanidentifier

Inassemblylanguage,avariablecorrespondstoadatamemorylocationthatistaggedwithalabel.Thelabelistheidentifier.Forexample,count.data5Inourassemblylanguage,wehadnorulesforformingidentifiers,butinmosthighlevellanguages,onlycertaincombinationsofcharacterscanbeused.

JavaRulesforCreatingIdentifiersUseanycombinationofdigits,letters,and_(theunderscoresymbol),butdon'tstartwithadigit.Javaisacase-sensitivelanguagei.e.eachofthefollowingisdifferent:

this THIS thIS

ThIs...Anidentifiercanbeofanylength.Aprogrammer-chosenidentifiermaynotbeareservedwordi.e.awordintheJavalanguagesuchasclass,public,int,etc.StrongTypingStrongtyping

TherequirementthatonlyavalueofthepropertypecanbestoredintoavariableDatatypeAdescriptionofthesetofvaluesandthebasicsetofoperationsthatcanbeappliedtovaluesofthetypeJavaisstronglytyped.PrimitiveDataTypesinJavaandManyOtherHigh-LevelProgrammingLanguagesIntegernumbersRealnumbersCharactersBooleanvaluesStringsIntegers(整型)Typicallythesearewholenumbers,theirnegatives,andzero.TherangeallowedvariesdependinguponhowmanybytesareassignedtorepresentanintegervalueSomehigh-levellanguagessupportseveralintegertypesofdifferentsizes–i.e.short,long,Operationsthatcanbeappliedtointegersarethestandardarithmetic(add,subtract,multiply,divide)andrelationaloperations(equality,lessthan,lessthanorequalto,greaterthan,greaterthanorequalto,inequality).Reals

(实数型)Thesearetypicallyfractionalnumbers.Liketheintegerdatatype,therangevariesdependingonthenumberofbytesassignedtorepresentarealnumberManyhigh-levellanguagessupporttwosizesofrealnumbersTheoperationsthatcanbeappliedtorealnumbersarethesameasthosethatcanbeappliedtointegernumbersRecall-Toacomputerscientist,2and2.0aredifferentastheyarestoreddifferently!Thefirstisaninteger;thesecondisareal.Characters(字符型)IttakesonebytetorepresentcharactersintheASCIIcharactersetTwobytesareneededtorepresentcharactersintheUnicodecharactersetOurEnglishalphabetisrepresentedinASCII,whichisasubsetofUnicodeApplyingarithmeticoperationstocharactersdoesn’tmakemuchsenseComparingcharactersdoesmakesense,sotherelationaloperatorscanbeappliedtocharactersThemeaningof“lessthan”and“greaterthan”whenappliedtocharactersis“comesbefore”and“comesafter”inthecharactersetBoolean(布尔)TheBooleandatatypeconsistsoftwovalues:trueandfalseNotallhigh-levellanguagessupporttheBooleandatatypeIfalanguagedoesnotsupportaBooleantype,thenyoucansimulateBooleanvaluesbysayingthattheBooleanvaluetrueisrepresentedby1andfalseisrepresentedby0Strings(字符串)AstringisasequenceofcharactersconsideredasonedatavalueForexample:“Thisisastring.”Contains17characters:oneuppercaseletter,12lowercaseletters,threeblanks,andaperiodNotalllanguagessupportstringsasadatatype.TheoperationsdefinedonstringsvaryfromlanguagetolanguageTheyincludeconcatenationofstrings(i.e.pastingthemtogether),comparisonofstringsintermsoflexicographicorder(i.e.alphabeticalorder)theextractingofsubstrings.DeclarationsDeclaration

Astatementthatassociatesanidentifierwithavariable,anaction,orsomeotherentitywithinthelanguagethatcanbegivenanamesothattheprogrammercanrefertothatitembynameDeclarations8-26DeclarationsinJavaEachidentifier(variable)mustbedeclared.Avariabledeclarationconsistsofadatatypefollowedbyalistofoneormoreidentifiersofthattype.Javahasmany"primitive"datatypesthatcanbeused.Oneswewilluse:

intamount;//integerdeclarationdoublesize,height;//realdeclarationcharanswer;//characterdeclarationStringName;//stringdeclaration

booleanx;Thecomputerneedstoknowthetypethatthebitsrepresent.AssignmentstatementAssignmentstatement

Anactionstatement(notadeclaration)thatsaystoevaluatetheexpressionontheright-handsideofthesymbolandstorethatvalueintothememorylocationnamedontheleft-handsideAssignmentsinJavaFormat:

Examples:

intA,B,C;//declarationscharletter=‘A’;//declarationandassignmentB=2;//assignmentsC=5;A=B+C;A=A+1;//ThisisavalidassignmentArithmeticoperations:

+,-,*,/,%variable=expression;ConstantsNamedconstant

Alocationinmemory,referencedbyanidentifier,thatcontainsadatavaluethatcannotbechangedduringtherunoftheprogram.Format:finaltypevariable=value;Examples:finaldoublePI=3.14;finalStringmyName=“Irina”;finalint

courseID=171;AssignmentStatementPage238PracticeProblemsNewNumber

andNextareintegervariablesinaJavaprogram.WriteastatementtoassignthevalueofNewNumbertoNext.WhatwillbethevalueofAverageafterthefollowingstatementsareexecuted?intTotal=277,Number=5;doubleAverage;Average=Total/Number;Next=NewNumber;Thevalueofaverageis55(integerdivision),butitisstoredasadouble–i.e.55.0InputinJavaUntilVersion5.0,Javawasnoteasytouseforkeyboardinput.Consequently,thetextintroducedaclasscalledConsole

tomakeinputsimpler.ThisisnotastandardclassintheJavalanguage.Thisclassallowspromptingandinputtooccuratthesametimeusing:

readInt,readDouble,readCharExample:doublespeed=Console.readInt("Enterthespeedinmph:");Youneedtoknowthisonlysoyoucanreadtheprogramsinthetext.WewilluseadifferentclassaswewilluseVersion5.0ofJava.PracticeProblemDeclareanintegervaluecalledquantity.

WriteastatementusingtheConsoleclassthatpromptstheusertoenteranintegervalueinapreviouslydeclaredvariablecalledquantity.intquantity;quantity=Console.readInt(“Enteranintegervalueforquantity.”);OutputinJavaFormatSystem.out.println(string);Ifthestringisempty,ablanklineisprinted.Thestringcanbecomposedusingtheconcatenationoperation,+,thatcombinesvaluesandstrings.Example:inti=10;intj=20;System.out.println("Thiswilloutputthevalueofi"+i+"andthevalueofj"+j+".");Becareful:Ifyouincludeblankswhenyousplitastringforoutput:System.out.println(“Doingthiscouldputextrablanks whereyoudon’twantthem”);println

vsprintSystem.out.println(string);printsthestringandthenissuesaCRcharacterwhichbringsthecursordowntothenextline.System.out.print(string);printsthestringandleavesthecursorattheendofthestring.Thisoneisusedwhenpromptingforinput.PracticeProblemsAprogramhascomputedavalueforthevariableaveragethatrepresentstheaveragehightemperatureinSanDiegoforthemonthofMay.Writeanappropriateoutputstatement.Whatwillappearonthescreenaftertheexecutionofthefollowingstatement?

System.out.println(“Thisis”+”goodbye”+”,Steve”);System.out.println(“Theaveragehightemperatureis”+average);Thisisgoodbye,SteveWe'llUseaClassIntroducedinJava5.0forInput–Namely,theScannerclass//Exampleofuseofscanner

importjava.util.Scanner;//inputtheScannerlibrary

publicclassExample2

{publicstaticvoidmain(String[]args)

{Scannersc=newScanner(System.in);

System.out.print("Enterthefirstnumber");

intfirst=sc.nextInt();

System.out.print("Enterthesecondnumber");

intsecond=sc.nextInt();

intsum=first+second;

System.out.println("Thesumis"+sum);

}

}

InputSummaryImporttheScannerclasswith:importjava.util.Scanner;Setuptheinputsream: Scannerstdin=newScanner(System.in);wherestdinisyourchoiceofanameforthescanner.Toinputanything,firstissueaprompt:

System.out.print("Enteranddescribeithere>");InputUsingtheScannerClassToinputaninteger:

anint=stdin.nextInt();or

int

anint=stdin.nextInt();ifthevariableanintisnotdeclared.Toinputadouble:doubleadouble=stdin.nextDouble();Toinputastring:Stringastring=stdin.nextLine();Thisstoresinastringeverythingfromthescannertotheendoftheline.HandlingcharDataScannersc=newScanner(System.in);

System.out.print("Answeryesorno:");

ans=sc.next();//readsnextstringfromthelineNowtoseewhattheansweris,youmusttestifthevariableansisayornot.Therearetwowaystodothis:if(ans.charAt(0)=='y')….orif(ans.equals("y"))…Caution-watchthetypeofquote.''denotesacharacter""denotesastringMostofmyexamplesontheslideswillusetheConsoleclassasthecodeisabitsmallerandfitsontheslidesbetter.ControlStructuresControlstructureAninstructionthatdeterminestheorderinwhichotherinstructionsinaprogramareexecutedStructuredprogrammingAprogrammingmethodologyinwhicheachlogicalunitofaprogramshouldhavejustoneentryandoneexitSequence,selectionstatements,loopingstatements,andsubprogramstatementsarecontrolstructuresBothselectionanditerationrequiretheuseofaBooleanexpressionBooleanExpressionsABooleanvariableisalocationinmemorythatcancontaineithertrueorfalse.Typically,falseisrepresentedasa0andtrueasa1oranynonzerointeger.Booleanexpression

Asequenceofidentifiers,separatedbycompatibleoperators,thatevaluatestotrueorfalseBooleanexpressioncanbeABooleanvariableAnarithmeticexpressionfollowedbyarelationaloperatorfollowedbyanarithmeticexpressionABooleanexpressionfollowedbyaBooleanoperatorfollowedbyaBooleanexpressionBooleanExpressionsArelationaloperatorbetweentwoarithmeticexpressionsisaskingiftherelationshipexistsbetweenthetwoexpressionsForexample,

xValue<yValueAnansweristrueorfalse.==!=JavaCaution:equaltois==,not=inJava.BooleanOperators

inJavaOperatorSymbol!not&&and||orBecarefultonotuseasingle&orasingle|asthosearedifferentoperations.Trueorfalsefora=2;b=3;andc=-1 1.(a<b)&&(a>c) 2.(a!=b+c)||(b-c>a) 3.!(a+b>c)||(a<=b) 4.(a-b>=c)||a>c&&b-2<cAnswers:truetruetrue4.trueSelectionStatementsTheif

statementallowstheprogramtotestthestate

oftheprogramvariablesusingaBooleanexpressionSelectionStatements

Flowofcontrolof

if-then-elsestatementSelectionStatementsSelectioninJavaFormat:if(Booleanexpression){Firstsetofstatements}else{Secondsetofstatements}if(A>B){Max=A;Min=B;}else{Max=B;Min=A;}ImportantNote:TheBooleanconditionisinparentheses,elsepartmaybeabsent,nobracketsarenecessaryifasetconsistsofonestatement.Example:SelectionStatementsinPseudocodeSameinJavaif(temp>90)

System.out.println(“Texasweather:wearshorts”);elseif(temp>70)

System.out.println(“Idealweather:shortsleevesarefine”);elseif(temp>50)

System.out.println(“Alittlechilly:wearalightjacket”);elseif(temp>32)

System.out.println(“Texasweather:wearaheavycoat”);else

System.out.println(“Stayinside”);PracticeProblemWhatistheoutputfromthefollowingsectionofcode?intnumber1=15;intnumber2=7;if(number1>=number2)System.out.println(2*number1);elseSystem.out.println(2*number2);30PracticeProblemWhatisanoutputfromthefollowingsectionofcode?

int

quotaThisMonth=7;

int

quotaLastMonth=quotaThisMonth+1;if((quotaThisMonth>quotaLastMonth)||(quotaLastMonth>=8)){System.out.println(“Yes”);

quotaLastMonth=quotaLastMonth+1;}else{System.out.println(“No”);

quotaThisMonth=quotaThisMonth+1;}YesPracticeProblemsWhatistheoutputfromthefollowingcodesegments?inta=1,b=2,c=3;if(a<b) System.out.println(“Yes”);elseSystem.out.println(“No’);System.out.println(“OK”);YesOKinta=1,b=2,c=3;if(a>b) System.out.println(“Yes”);System.out.println(“OK”);OKOtherSelectionCommands

Theif-then-elsestatementisa2-waybranchingcommand.Mostlanguagesprovideanadditionalmultiwaybranchingcommandwhichiscalledsomethingsuchasaswitchoracasestatement.Wewon’tintroducethesyntaxforthosehere.Asweknowfromtheearliercommentthatsaidwhichcommandssufficedtowriteanyalgorithm,weknowtheif-then-elseisallweneedreally.Theotherselectioncommandsjustmakesomecodingabiteasierfortheprogrammer.Supposeweencountera4-waybranchsituation:ifclassisoutput1freshman2sophomore3junior4seniorIfstatementscanbenestedinordertoprovidemultiwaybranches.if(class==1)System.out.println(“freshman”);elseif(class==2)System.out.println(“sophomore”);elseif(class==3)System.out.println(“junior”);elseif(class==4)System.out.println(“senior”);if(class==1)System.out.println(“freshman”);elseif(class==2)System.out.println(“sophomore”);elseif(class==3)System.out.println(“junior”);elseSystem.out.println(“senior”);if(class==1)System.out.println(“freshman”);if(class==2)System.out.println(“sophomore”);if(class==3)System.out.println(“junior”);if(class==4)System.out.println(“senior”);Comparethesethreepiecesofcode: Dotheyprintthesamethingforallvaluesofclass? Dotheydothesameamountofwork?if(class==1)System.out.println(“freshman”);elseif(class==2)System.out.println(“sophomore”);elseif(class==3)System.out.println(“junior”);elseif(class==4)System.out.println(“senior”);LoopingStatementsThewhilestatementisusedtorepeatacourseofactionTherearetwodistincttypesofrepetitions:Count-controlledloopsEvent-controlled

loopsCount-ControlledLoopsRepeataspecifiednumberoftimesUseofaspecialvariablecalledaloopcontrolvariableintcount=1while(count<=limit){…count=count+1;}Count-controlledloopsLoopingStatementsEvent-controlledloopsThenumberofrepetitionsiscontrolledbyaneventthatoccurswithinthebodyoftheloopitselfintn=Console.readInt(“Enteraninteger”);//initializeeventwhile(n>=0) //Testevent{… //Bodyofloopn=Console.readInt(“Enteraninteger”); //Updateevent}PracticeProblemWhatisanoutputfromthefollowingsectionofthecode?

intscores=1;while(scores<20){scores=scores+2;

System.out.println(scores);}3579111315171921PracticeProblemHowmanytimeswillthestatementwiththecommentbeexecutedinthefollowingsectionofcode?

intleft=10;

intright=20;while(left<=right){

System.out.println(left);//Thisstatementleft=left+2;}101214161820–sixtimesAdditionalLoopingCommands

Thewhileloopisknownasapretestloop.Theconditionistestedbeforetheloopisencountered.Iftheconditionisfalse,theloopisnotentered.Wesawearlierthatthewhileloopwastheonlyloopthatwasneededtowriteanyalgorithm.However,mostlanguagesprovideatleasttwootherkindsofloops:Aposttestloop(oftencalledsomethinglikearepeat-untilloop.)Aspecialcount-controlledloopwherethecounterisinitialized,tested,andincrementedautomatically(oftencalledsomethinglikeaforloop).Wewon’tshowthosehere.StoringDatainMoreComplexStructuresThanaSingleCell

Weoftenneeddatastoredinstructuresmorecomplicatedthansinglecells.Allprogramminglanguageshavesomebasicstructures.Modernprogramminglanguageshavemanytypesofcomplexstructuresthancanbeused.Forexample,ifyouwantedtomaintainalistofstudentsinaclassandtheirgrades,youmightwanttokeepsuchinformationasthefollowing:CPSC171Grades

SurnameFirstnameMiddleinitialEmailaddressLab1...LabkHomeworkTest1Test2Test3FinalCourseAlthoughmanyofthesecouldbehandledwithasinglevariableforeach,ifwehavealotofLabgrades,usingadifferentvariableforeachgradeisapain.MultipleDataThatisSimilar

Supposewehadmany,manypiecesofdatasuchasgrades,andweneeded1000ofthese.Wouldyouwanttousegrade0,grade1,grade2,...,grade999forvariablenames?Thinkofthefactthatyouwouldneedtodeclareallofthese.Ifyouwantedtoinputvaluesyouwouldhavetodo1000inputstatements.Outputforallwouldrequire1000outputstatements.And,evenworst,thinkoftryingtofindtheaverageofallofthese–youwouldneedahugearithmeticstatementtotal=(grade0+grade1+...+grade999)/1000;andprogramminglanguagescan’tdealwith...Almostalllanguagessupportsomethingtohandlethis.Arrays

AnarrayisanamedcollectionofhomogeneousitemsinwhichindividualitemsareaccessedbytheirplacewithinthecollectionTheplacewithinthecollectioniscalledanindexint[]myArray=newint[10]; //createsanarrayof10integersmyArray[0]=1; //setthefirstelementto1myArray[8]=myArray[0]; //setthenexttolastelementto//thevalueofthefirstelement11myArrayAnArray

ThatHasBeenGivenValues

i.e.Initialized

Indices…NowWeCanHandletheGradeAverageProblem–Notetheuseoftheindex!!!int[]grades=newint[1000];//assumesintegergradesintcount=0,sum=0;doubleaverage;//getinputandaddatsametimewhile(count<=1000){

System.out.println(“Enterthegradeforstudent“+ count);

grade[count]=Console.readInt(“>"); sum=sum+grade[count]; count=count+1;}average=sum/1000.0;Note:The<=wouldallowareferencetograde[1000]whichdoesn'texist.Changeto<(ordeclaregradesasnewint[1001])TheIndexofanArrayCanBeComputed!!!

Thus,thisisalegalreference:myArray[i+j]Anytimeyouhavealotofvariableswhicharestoringthesamekindofdata,usinganarrayhelpsyou

declarethevariableseasily

docomputingwithloops doI/Owiththevariables.Thekindofarrayintroducedsofarhasoneindexandiscalleda1-dimensionalarray.Mostlanguagessupportanarbitrarylargenumberofarrays.TwoDimensionalArraysdouble[][]myTable=newdouble[2][3];Thisreservesmemoryforkeep6realnumberssequentially.But,wecanthinkofthemasdisplayedinatablewith2rowsand3columns.myTable[0][2]=2.3;2.310120Remember,numberingStartswithzero!SummarySoFarWecandoinputandoutput.Wecanassignvaluestovariableswithintheprogram.Wecandirecttheflowofcontrolbyusingconditionalanditerativestatements.Otherthingstoremember:aprologuecommenttoexplainwhattheprogramdoesandtheauthor.theclassheaderpublicclassClassNamethemainmethodheader

publicstaticvoidmain(String[]args)variabledeclarations.MorePracticeProblemsWriteacompleteJavaprogramtoreadtheuser’sfirstandlastinitialsandwritethem.//Programtoreadandwriteuser’sinitials//Author’snamehere10/19/05publicclassInitials{publicstaticvoidmain(String[]args){charFisrtInitial,SecondInitial;

FirstInitial=Console.readChar("Enterthefirstinitial");

SecondInitial=Console.readChar("Enterthesecondinitial");

System.out.println(FirstInitial+“.”+SecondInitial+“.”);}}MorePracticeProblemsWriteacompleteJavaprogramthatasksforthepriceofanitemandthequantitytopurchase,andwritesthecost.//Programtocomputethecost//Author’snamehere10/19/05publicclassCost{publicstaticvoidmain(String[]args){doubleprice;

intamount;price=Console.readDouble("Entertheprice");amount=Console.readInt("Entertheamount");

System.out.println(“Thecostis“+(price*amount));}}MorePracticeProblemsWriteacompleteJavaprogramthatasksforanumber.Ifthenumberislessthan5,itiswritten,otherwisetwicethatnumberiswritten.//Programtoprocessanumber//Author’snamehere10/19/05publicclassNumber{publicstaticvoidmain(String[]args){

intnumber;number=Console.readInt("Enteranintegernumber");if(number<5)

System.out.println(number);elseSystem.out.println((2*number));}}MorePracticeProblemsWriteacompleteJavaprogramthatasksforapositiveintegern,andthenwritesallthenumbersfrom1uptoandincludingn.//Programtoprintintegersfrom1ton//Author’snamehere10/19/05publicclassPrintIntegers{publicstaticvoidmain(String[]args){

intn,k=1;n=Console.readInt("Enterapositiveinteger");while(k<=n){

System.out.println(k);k=k+1;}}}Subprograms

Let'splanaparty.Todothis,wehaveseveraltaskstodowhichcouldbethoughtofasorganizedinahierarchicalfashion.Subprograms

Thistypeofbreakdowniscriticalinallowingustowriteverylargeprogramswhenteamsofpeoplemustworkonthedesignandthecoding.Infact,suchabreakdownisusefulforthesingleprogrammerasitallowsustotakeacomplextaskandbreakitintosimplertaskswhichwecanconceptualizeandhandleeasier.Infact,inscienceweoftendothis:Solvesimplerproblemsandcombinesolutionstohandleharderproblems!!!SubprogramsMostprogramminglanguagesprovidesomemeansof“modularizing”orsubdividingthecodeintosubunits.Thesesubunitsarecalledbydifferentnames:functions,subroutines,subprograms,procedures,methods,etc.Inthecases1wewillconsiderhere,thereisacallingprogram–thecodethatexplicitlyinvokesor callsthesubprogramthesubprogram–thecodethatbeginsexecuting whencalled1Thereareotherwaystocallasubprogram.Forexample,itmightbecalledbyaneventsuchasamouseclick.Thattypeofsubprogramisusedalotingraphicswork.SubprogramsBasically,inoursituation,therearetwotypesofsubprograms:1)Thosethatdoaparticulartask,whichmayincludeoutput,butdonotreturnanyvalueto

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

最新文档

评论

0/150

提交评论