內容簡介
本書重點講授在C/C++語言環境蘭請協下,編寫程式的思路和方法,涉及計算機語言、數據結構和常用算法等內容。全愚邀腳書內容豐富,強調動手實踐,深入淺出朽踏禁地引導讀者理危白元性思維和理性實踐,教學方法引人入勝,便於自學。
本書可作汗趨探戀為大專院校教材,亦可供凳旋婚刪從事計算獄坑機、自動化和相關領域的科研人員參考。
圖書目錄
BriefContents
.
Contentsxiii
0Introduction1
1AnIntroductiontoProgramming27
2DevelopingaProgram69
3SelectionStructures:MakingDecisions123
4RepetitionStructures:Looping177
5Arrays:ListsandTables239
6SequentialDataFiles301
StudySkills341
Glossary351
Index365
xI
Contents
0Introduction1
0.1ComputersEveryWhere1
0.ZABriefHistoryofComputers2
WhatisaComputers2
EarlyComputers2
PersonalComputers5
TOday'sComputers6
TheInternet7
O.3ComputerBasics9
TheCentralProcessingUnit10
InternalMemory11
MassStorageDevices12
InputDevices14
OutputDevices14
0.4SoftwareandProgrammingLanguages16
TypesofSoftware16
TypesofProgrammingLanguages18
ChapterReviewandEXercises21
1AnintroductiontoProgramming27
IntheEverydayWorld:YouAreAlreadyaProgrammer!28
1.1WhatisProgramming?28
AGeneralProblem-SolvingStrategy29
CreatingComputerPrograms:TheProgramDevelopmentCycle31
1.2BasicProgrammingConcepts3Z
ASimpleProgram32
ThePriceConversionProgram33
Datainput35
TheinputandWriteStatements36
xIII
.
XlvContents
UseInputPrompts37
OtherFormsofinput37
ProgramVariablesandConstants37
VariablesNames39
VariableNamesShouldBeMeaningful!39
What'sReallyGoingOnwithVariablesintheComputer?40
yGoingOnwithVariablesintheComputer?40
1.3DataProcessingandOutput41
ProcessingData41
TheSetStatement42
AssigningandReassigningValuestoVariables42
rumf;airy+ryd7
OperationsonData43
HierarchyofODerations44
yofOperations44
DataOutput46
TheWriteStatementRevisited47
AnnotateYourOutput48
1.4TyDesofData50
ypesofData50
NumericData51
Integers51
b
DividingIntegers52
oIntegers52
RealNumbers52
TheDeclareStatement53
TheLastWordonPriceConversion54
ScientificandExponentialNotation55
CharacterStringData57
TheCharacterDataType58
ape58
OperatingonStrings58
ChanterReviewandEXercises6J
pierReviewandEXercises6J
2DevelopingaProgram69
IntheEverydayWorld:PlanningtoProgram7YouNeedaPlan7O
2.1TheProgramDevelopmentCycle71
TheProcessofDevelopingaProgram71
AnalyzetheProblem71
yzetheProblem71
DesigntheProgram72
antheProgram72
CodetheProgram73
TesttheProgram74
AdditionalStepsintheCycle76
2.2ProgramDesign80
ModularProgramming80
UsingModulesandSubmodules81
BenefitsofModularProgramming81
ProvideaWelcomeMessageattheBeginningofYourProgram86
Contentsxv
2.3Coding,Documenting,andTestingaProgram90
CodingandDocumentingaProgram90
HowCanaComputerKnowWhattoignore?91
ExternalDocumentation93
TypesofErrors94
2.4CommercialPrograms:TestingandDocumenting95
TheTestingPhaseRevisited96
ExternalDocumentation97
TheUser'sGuide97
TheProgramMaintenanceManual98
DesignDocumentation98
TradeStudyDocumentation99
2.5StructuredProgramming100
Flowcharts100
ControlStructures101
TheSequentialStructure101
LooporRepetitionStructures103
DecisionorSelectionStructures103
Z.6AnintroductiontoOOPandCUls106
GUlsandEvent-DrivenProgramming106
Object-OrientedProgramming110
Object-OrientedProgrammingDesign112
EveryoneNeedsStructuredProgramming114
ChapterReviewandEXercises]15
3SelectionStructUres:MakingDecisions123
IntheEverydayWorld:Decisions,decisions,decisions...IZ4
3.1AnIntroductiontoSelectionStructures125
TypesofSelectionStructures125
Single-andDual-AlternativeStructures127
Single-AlternativeStructure:Theif-ThenStructure127
Dual-AlternativeStructure:Theif-Then-ElseStructure129
3.2RelationalandLogicalOperators133
RelationalOperators133
ALittleMoreExplanationaboutRelationalOperators134
LogicalOperators137
TruthTablesfortheOR,AND,andNOTOperators138
CompoundingtheCompoundConditionissue140
HierarchyofOperations143
3.3SelectingfromSeveralAlternatives146
UsingifStructures147
TheActionofaCaseStatement150
.
XviContents
3.4ApplicationsofSelectionStructures154
DefensiveProgramming154
Menu-DrivenPrograms158
3'5FOcusonProblemSolving:
ANewCarPriceCalculator161
ProblemStatement161
ProblemAnalVsis162
y3ls162
ProgramDesign162
blainDesign162
ProgramCode166
brainCode166
ProgramTest166
brainrest166
ChanterReviewandEXercises]67
pierReviewandEXercises]67
4RepetitionStructures:Looping177
IntheEverydayWOrld:Loops178
4.1AnIntroductiontoRepetitionStructures:Computers
NeverCetBored!179
ASimpleExampleofaLoop179
BewareoftheInfiniteLoop!181
RelationalandLogicalOperators183
Pre-TestandPost-TestLoops184
4.2CounteFControlledLoops189
ConstructingaCounter-ControlledLoop190
Summing'HowaComputerAdds190
CountingUP,Down,andEveryWay193
Built-InCounter-ControlledLoops193
TheCarefulBeauCounter197
4.3ApplicationsofRepetitionStructures202
UsingSentinel-ControlledLoopstoinputData202
DataValidation204
4.4NestedLoops215
NestedForLoops215
NestingOtherKindsofLoops218
NestingLoopsandSelectionStructures220
4'5FOcusonProblemSolving:
ACost,Revenue,andProfitProblem223
ProblemStatement223
ProblemAnalysis224
j>Is224
ProgramDesign226
ProgramCode229
brainCode229
ProgramTest230
braintest230
ChapterReviewandExercises232
pierReviewandExercises232
Contentsxvii
5Arrays:ListsandTables239
IntheEverydayWorld:Arrays24O
ydayWorld:Arrays24O
5'1One-DimensionalArrays241
ys241
ArrayBasics241
yBasics241
DeclaringArraVs242
bArrays242
ParallelArrays248
ys248
SomeAdvantagesofUsingArraVs252
besofUsingArrays252
5.ZSearchingandSortingArray256
gandSortingArrayS256
TheSerialSearchTechnique256
iheSerialSearchTechnique256
TheBubbleSortTechnique261
OtherSortsofSorting271
5'3OtherUsesofArrays272
ys272
StringsAsArraVsofCharacters277
e>AsArraysofCharacters272
DeclaringanArraVAsaDataTVDe272
banArrayAsaDataType272
StringLengthversusArraySizej74
oLengthversusArraySize274
5'4Two-DimensionalArray277
,s277
AnIntroductiontoTwo-DimensionalArrays277
ys277
DeclaringTwo-DimensionalArraVs278
btwo-DimensionalArrays278
UsingTwo-DimensionalArraVs279
atwo-DimensionalArrays279
5.5FocusonProblemSolving.
5.
AninvoicePreparationProgram284
ProblemStatement284
ProblemAnalysis285
ysls285
ProgramDesign285
ProgramCode290
ProgramTest291
ChanterReviewandExercises292
pierReviewandExercises292
6SequentialDataFiles301
IntheEvervdaVWOrld:DataFiles302
ydayWOrld:DataFiles302
6.1AnIntroductiontoDataFiles3O3
FileBasics303
CreatingandReadingSeauentialFiles306
bandReadingSequentialFiles306
6.ZModifyingaSeauentialFile312
yingaSequentialFile312
DeletingRecords314
bRecords314
ModifVingRecords316
yingRecords316
InsertingRecords317
bRecords317
UsingArraVsinFileMaintenance320
oArraysinFileMaintenance320
6.3MereingSeauentialFiles322
gingSequentialFiles322
...
xvillContents
6.4FocusonProblemSolving:
ControlBreakProcessing326
ProblemStatement326
ProblemAnalysis327
j
ProgramDesign328
ProgramCode331
ProgramTest332
blainrest332
ChanterReviewandEXercises333
pierReviewandEXercises333
<..c1.II
studyskills341
ySkills341
Clossary351
y351
Index365
UsingModulesandSubmodules81
BenefitsofModularProgramming81
ProvideaWelcomeMessageattheBeginningofYourProgram86
Contentsxv
2.3Coding,Documenting,andTestingaProgram90
CodingandDocumentingaProgram90
HowCanaComputerKnowWhattoignore?91
ExternalDocumentation93
TypesofErrors94
2.4CommercialPrograms:TestingandDocumenting95
TheTestingPhaseRevisited96
ExternalDocumentation97
TheUser'sGuide97
TheProgramMaintenanceManual98
DesignDocumentation98
TradeStudyDocumentation99
2.5StructuredProgramming100
Flowcharts100
ControlStructures101
TheSequentialStructure101
LooporRepetitionStructures103
DecisionorSelectionStructures103
Z.6AnintroductiontoOOPandCUls106
GUlsandEvent-DrivenProgramming106
Object-OrientedProgramming110
Object-OrientedProgrammingDesign112
EveryoneNeedsStructuredProgramming114
ChapterReviewandEXercises]15
3SelectionStructUres:MakingDecisions123
IntheEverydayWorld:Decisions,decisions,decisions...IZ4
3.1AnIntroductiontoSelectionStructures125
TypesofSelectionStructures125
Single-andDual-AlternativeStructures127
Single-AlternativeStructure:Theif-ThenStructure127
Dual-AlternativeStructure:Theif-Then-ElseStructure129
3.2RelationalandLogicalOperators133
RelationalOperators133
ALittleMoreExplanationaboutRelationalOperators134
LogicalOperators137
TruthTablesfortheOR,AND,andNOTOperators138
CompoundingtheCompoundConditionissue140
HierarchyofOperations143
3.3SelectingfromSeveralAlternatives146
UsingifStructures147
TheActionofaCaseStatement150
.
XviContents
3.4ApplicationsofSelectionStructures154
DefensiveProgramming154
Menu-DrivenPrograms158
3'5FOcusonProblemSolving:
ANewCarPriceCalculator161
ProblemStatement161
ProblemAnalVsis162
y3ls162
ProgramDesign162
blainDesign162
ProgramCode166
brainCode166
ProgramTest166
brainrest166
ChanterReviewandEXercises]67
pierReviewandEXercises]67
4RepetitionStructures:Looping177
IntheEverydayWOrld:Loops178
4.1AnIntroductiontoRepetitionStructures:Computers
NeverCetBored!179
ASimpleExampleofaLoop179
BewareoftheInfiniteLoop!181
RelationalandLogicalOperators183
Pre-TestandPost-TestLoops184
4.2CounteFControlledLoops189
ConstructingaCounter-ControlledLoop190
Summing'HowaComputerAdds190
CountingUP,Down,andEveryWay193
Built-InCounter-ControlledLoops193
TheCarefulBeauCounter197
4.3ApplicationsofRepetitionStructures202
UsingSentinel-ControlledLoopstoinputData202
DataValidation204
4.4NestedLoops215
NestedForLoops215
NestingOtherKindsofLoops218
NestingLoopsandSelectionStructures220
4'5FOcusonProblemSolving:
ACost,Revenue,andProfitProblem223
ProblemStatement223
ProblemAnalysis224
j>Is224
ProgramDesign226
ProgramCode229
brainCode229
ProgramTest230
braintest230
ChapterReviewandExercises232
pierReviewandExercises232
Contentsxvii
5Arrays:ListsandTables239
IntheEverydayWorld:Arrays24O
ydayWorld:Arrays24O
5'1One-DimensionalArrays241
ys241
ArrayBasics241
yBasics241
DeclaringArraVs242
bArrays242
ParallelArrays248
ys248
SomeAdvantagesofUsingArraVs252
besofUsingArrays252
5.ZSearchingandSortingArray256
gandSortingArrayS256
TheSerialSearchTechnique256
iheSerialSearchTechnique256
TheBubbleSortTechnique261
OtherSortsofSorting271
5'3OtherUsesofArrays272
ys272
StringsAsArraVsofCharacters277
e>AsArraysofCharacters272
DeclaringanArraVAsaDataTVDe272
banArrayAsaDataType272
StringLengthversusArraySizej74
oLengthversusArraySize274
5'4Two-DimensionalArray277
,s277
AnIntroductiontoTwo-DimensionalArrays277
ys277
DeclaringTwo-DimensionalArraVs278
btwo-DimensionalArrays278
UsingTwo-DimensionalArraVs279
atwo-DimensionalArrays279
5.5FocusonProblemSolving.
5.
AninvoicePreparationProgram284
ProblemStatement284
ProblemAnalysis285
ysls285
ProgramDesign285
ProgramCode290
ProgramTest291
ChanterReviewandExercises292
pierReviewandExercises292
6SequentialDataFiles301
IntheEvervdaVWOrld:DataFiles302
ydayWOrld:DataFiles302
6.1AnIntroductiontoDataFiles3O3
FileBasics303
CreatingandReadingSeauentialFiles306
bandReadingSequentialFiles306
6.ZModifyingaSeauentialFile312
yingaSequentialFile312
DeletingRecords314
bRecords314
ModifVingRecords316
yingRecords316
InsertingRecords317
bRecords317
UsingArraVsinFileMaintenance320
oArraysinFileMaintenance320
6.3MereingSeauentialFiles322
gingSequentialFiles322
...
xvillContents
6.4FocusonProblemSolving:
ControlBreakProcessing326
ProblemStatement326
ProblemAnalysis327
j
ProgramDesign328
ProgramCode331
ProgramTest332
blainrest332
ChanterReviewandEXercises333
pierReviewandEXercises333
<..c1.II
studyskills341
ySkills341
Clossary351
y351
Index365