C++课程设计学生成绩信息管理系统包括doc报告文档exe可执行文件cpp源代码以及txt格式源Word下载.docx

上传人:b****1 文档编号:3699373 上传时间:2023-05-02 格式:DOCX 页数:25 大小:154.46KB
下载 相关 举报
C++课程设计学生成绩信息管理系统包括doc报告文档exe可执行文件cpp源代码以及txt格式源Word下载.docx_第1页
第1页 / 共25页
C++课程设计学生成绩信息管理系统包括doc报告文档exe可执行文件cpp源代码以及txt格式源Word下载.docx_第2页
第2页 / 共25页
C++课程设计学生成绩信息管理系统包括doc报告文档exe可执行文件cpp源代码以及txt格式源Word下载.docx_第3页
第3页 / 共25页
C++课程设计学生成绩信息管理系统包括doc报告文档exe可执行文件cpp源代码以及txt格式源Word下载.docx_第4页
第4页 / 共25页
C++课程设计学生成绩信息管理系统包括doc报告文档exe可执行文件cpp源代码以及txt格式源Word下载.docx_第5页
第5页 / 共25页
C++课程设计学生成绩信息管理系统包括doc报告文档exe可执行文件cpp源代码以及txt格式源Word下载.docx_第6页
第6页 / 共25页
C++课程设计学生成绩信息管理系统包括doc报告文档exe可执行文件cpp源代码以及txt格式源Word下载.docx_第7页
第7页 / 共25页
C++课程设计学生成绩信息管理系统包括doc报告文档exe可执行文件cpp源代码以及txt格式源Word下载.docx_第8页
第8页 / 共25页
C++课程设计学生成绩信息管理系统包括doc报告文档exe可执行文件cpp源代码以及txt格式源Word下载.docx_第9页
第9页 / 共25页
C++课程设计学生成绩信息管理系统包括doc报告文档exe可执行文件cpp源代码以及txt格式源Word下载.docx_第10页
第10页 / 共25页
C++课程设计学生成绩信息管理系统包括doc报告文档exe可执行文件cpp源代码以及txt格式源Word下载.docx_第11页
第11页 / 共25页
C++课程设计学生成绩信息管理系统包括doc报告文档exe可执行文件cpp源代码以及txt格式源Word下载.docx_第12页
第12页 / 共25页
C++课程设计学生成绩信息管理系统包括doc报告文档exe可执行文件cpp源代码以及txt格式源Word下载.docx_第13页
第13页 / 共25页
C++课程设计学生成绩信息管理系统包括doc报告文档exe可执行文件cpp源代码以及txt格式源Word下载.docx_第14页
第14页 / 共25页
C++课程设计学生成绩信息管理系统包括doc报告文档exe可执行文件cpp源代码以及txt格式源Word下载.docx_第15页
第15页 / 共25页
C++课程设计学生成绩信息管理系统包括doc报告文档exe可执行文件cpp源代码以及txt格式源Word下载.docx_第16页
第16页 / 共25页
C++课程设计学生成绩信息管理系统包括doc报告文档exe可执行文件cpp源代码以及txt格式源Word下载.docx_第17页
第17页 / 共25页
C++课程设计学生成绩信息管理系统包括doc报告文档exe可执行文件cpp源代码以及txt格式源Word下载.docx_第18页
第18页 / 共25页
C++课程设计学生成绩信息管理系统包括doc报告文档exe可执行文件cpp源代码以及txt格式源Word下载.docx_第19页
第19页 / 共25页
C++课程设计学生成绩信息管理系统包括doc报告文档exe可执行文件cpp源代码以及txt格式源Word下载.docx_第20页
第20页 / 共25页
亲,该文档总共25页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

C++课程设计学生成绩信息管理系统包括doc报告文档exe可执行文件cpp源代码以及txt格式源Word下载.docx

《C++课程设计学生成绩信息管理系统包括doc报告文档exe可执行文件cpp源代码以及txt格式源Word下载.docx》由会员分享,可在线阅读,更多相关《C++课程设计学生成绩信息管理系统包括doc报告文档exe可执行文件cpp源代码以及txt格式源Word下载.docx(25页珍藏版)》请在冰点文库上搜索。

C++课程设计学生成绩信息管理系统包括doc报告文档exe可执行文件cpp源代码以及txt格式源Word下载.docx

time/t,就不允许修改系统时间了(缺点:

仅仅显示小时和分钟)

#include<

usingnamespacestd;

voidmain()

{

system("

time/t"

pause"

}

改变DOS字体颜色

colorob"

注:

当system(“colorob”)中的ob变为相应的数字时,DOS屏幕字体变为相应的颜色

改变DOS标题

title王万腾"

打印出系统日期

date"

date/t"

for_each的简单应用

#include<

vector>

string>

algorithm>

//特别注意:

for_each()还是在algorithm头文件中定义的来

voidprint_i(intt)

{

cout<

<

t<

ends;

}

intmain()

inta[]={1,2,3,4,5,6,7,8,9,10,11,12,13};

vector<

int>

elements(a,a+13);

for_each(elements.begin(),elements.end(),print_i);

endl;

return0;

strings("

WangWanteng"

string:

:

size_typelen2=s.size();

"

s.capacity():

s.capacity()<

ends<

s.size():

len2<

总结:

若s为一字符串,则s.size()==s.length(),s.capacity()总比s.size()或s.length()大4个字符

string的substr()

strings1("

MaYu"

s1=s.substr(4,3);

s1<

上例:

s.substr(4,3)是指从s串第(4+1)个字符开始往后数3个字符返回

关于swap()的传说

Wangwanteng"

王万腾"

swap(s,s1);

inta=1;

intb=2;

swap(a,b);

a<

s<

FunctionObjects

Definition

Afunctionobjectisanobjecttowhichthefunctioncalloperatorcanbeapplied.Typically,itisaclassthatdefinesthefunctioncalloperator(operator()())asamemberfunction.Whenafunctionobjectisusedasafunction,thefunctioncalloperatorisinvokedwheneverthefunctioniscalled.Considerthefollowingclassdefinition:

classbiggerThanThree

public:

booloperator()(intval)const

{returnval>

3;

}

};

IfwecreateaninstanceofclassbiggerThanThree,everytimewereferencethisobjectusingthefunctioncallsyntax,thefunctioncalloperatormemberfunctionisinvoked.Togeneralizethisclass,weaddaconstructorandaconstantdatamember,whichissetbytheconstructor:

classbiggerThan

constinttestValue;

biggerThan(intx):

testValue(x){}

booloperator()(intval)const

{returnval>

testValue;

TheresultisageneralbiggerthanXfunction,wherethevalueofXisdeterminedwhenwecreateaninstanceoftheclass.Wecandoso,forexample,asanargumenttooneofthegenericfunctionsthatrequireapredicate.Inthismannerthefollowingcodefindsthefirstvalueinalistthatislargerthan12:

std:

list<

iteratorfirstBig=

std:

find_if(aList.begin(),aList.end(),biggerThan(12));

3.2.2Use

Thereareanumberofsituationswhereitisconvenienttosubstitutefunctionobjectsinplaceoffunctions:

touseanexistingfunctionobjectprovidedbytheC++StandardLibraryinsteadofanewfunction;

toimproveexecutionbyusinginlinefunctioncalls;

andtoallowafunctionobjecttoaccessorsetstateinformationthatisheldbyanobject.Let'

sdealwitheachoftheseinthenextthreesections.

3.2.2.1ToEmployExistingC++StandardLibraryFunctionObjects

Table 

5illustratesthefunctionobjectsprovidedbytheC++StandardLibrary.

5:

FunctionobjectsprovidedbytheC++StandardLibrary 

Functionobject

Implementedoperations

Arithmeticfunctions

plus

additionx+y

minus

subtractionx-y

multiplies

multiplicationx*y

divides

divisionx/y

modulus

remainderx%y

negate

negation-x

Comparisonfunctions

equal_to

equalitytestx==y

not_equal_to

inequalitytestx!

=y

greater

greater-thancomparisonx>

y

less

less-thancomparisonx<

greater_equal

greaterthanorequalcomparisonx>

less_equal

lessthanorequalcomparisonx<

Logicalfunctions

logical_and

logicalconjunctionx&

&

logical_or

logicaldisjunctionx||y

logical_not

logicalnegation!

x

Let'

slookatacoupleofexamplesthatshowhowthesemightbeused.Thefirstexampleusesstd:

plus<

()tocomputetheby-elementadditionoftwolistsofintegervalues,placingtheresultbackintothefirstlist.Thiscanbeperformedbythefollowingcode:

transform(listOne.begin(),listOne.end(),listTwo.begin(),

listOne.begin(),std:

());

Thesecondexamplenegateseveryelementinavectorofbooleanvalues:

transform(aVec.begin(),aVec.end(),aVec.begin(),

logical_not<

bool>

ThebaseclasstemplatesusedbytheC++StandardLibrarytodefinethefunctionsinTable 

5arealsoavailableforcreatingnewunaryandbinaryfunctionobjects.Theclasstemplatesunary_functionandbinary_functionaredefinedintheheader<

functional>

.

Thebaseclassesaredefinedasfollows:

namespacestd{

template<

classArg,classResult>

structunary_function

typedefArgargument_type;

typedefResultresult_type;

classArg1,classArg2,classResult>

structbinary_function

typedefArg1first_argument_type;

typedefArg2second_argument_type;

AnexampleoftheuseofthesetemplatesisfoundinSection 

6.3.TherewewanttotakeabinaryfunctionoftypeWidgetandanargumentoftypeint,andcomparethewidgetidentificationnumberagainsttheintegervalue.Afunctiontodothisiswritteninthefollowingmanner:

structWidgetTester:

binary_function<

Widget,int,bool>

booloperator()(constWidget&

wid,inttestid)const

{returnwid.id==testid;

Theimportanceofinheritancefromoneofthetwobaseclasstemplatesbecomesapparentwhenelementaryfunctionobjectsarecomposedtoformcomplexexpressionsusingnegatorsandbinders,whichareexplainedinSection 

3.5.

3.2.2.2ToImproveExecution

Asecondreasontoconsiderusingfunctionobjectsinsteadoffunctionsisfastercode.Thedifferencebetweenafunctionandanobjectofaclassthatdefinesthememberoperator()()isthatfunctionsareconvertedtopointerswhenpassedasargumentstootherfunctions,thusincurringtheoverheadofafunctioncalleveniftheyaredeclaredinline.Inmanycasesaninvocationofafunctionobject,asintheexamplesonstd:

transform()inSection 

3.2.2.1,canbeexpandedin-line,eliminatingtheoverheadofafunctioncall.

3.2.2.3ToAccessorSetStateInformation

Thethirdmajorreasontouseafunctionobjectinplaceofafunctioniswheneachinvocationofthefunctionmustremembersomestatesetbyearlierinvocations.Anexampleofthisoccursinthecreationofagenerator,tobeusedwiththegenericalgorithmstd:

generate().Ageneratorissimplyafunctionobjectthattakesnoargumentsandreturnsanew(andpossiblydifferent)valueeachtimeitisinvoked.Themostcommonlyusedformofgeneratorisarandomnumbergenerator,butthereareotherusesfortheconcept.Asequencegeneratorsimplyreturnsthevaluesofanincreasingsequenceofnaturalnumbers(1,2,3,4andsoon).WecancallthisobjectiotaGenafterthesimilaroperationintheprogramminglanguageAPL,anddefineitasfollows:

classiotaGen

public:

iotaGen(intstart=0):

current(start){}

intoperator()(){returncurrent++;

private:

intcurrent;

Aniotaobjectmaintainsacurrentvalue,whichcanbesetbytheconstructor,ordefaultstozero.Eachtimethefunction-calloperatorisinvoked,thecurrentvalueisreturned,andalsoincremented.Usingthisobject,thefollowingcallontheC++StandardLibraryfunctionstd:

generate()initializesavectorof20elementswiththevalues1through20:

vector<

aVec(20);

generate(aVec.begin(),aVec.end(),iotaGen

(1));

Amorecomplexexampleofusingafunctionobjectoccursintheradixsortingexampleprogram,whichisgivenasanexampleofusingthelistdatatypeinSection 

6.3.Inthisprogramreferencesareinitializedinthefunctionobject,sothatduringthesequenceofinvocationsthefunctionobjectcanaccessandmodifylocalvaluesinthecallingprogram.

IntroductiontoIterators

TheconceptofiteratorsisfundamentaltousingthecontainerclassesandtheassociatedalgorithmsprovidedbytheC++StandardLibrary.Aniteratorisapointer-likeobjectusedtocyclethroughalltheelementsstoredinacontainer.Becausedifferentalgorithmsneedtotraversecontainersinavarietyoffashions,therearedifferentformsofiterators.EachcontainerclassintheC++StandardLibrarycangenerateaniteratorwithfunctionalityappropriatetothestoragetechniqueusedinimplementingthecontainer.ItisthecategoryofiteratorsrequiredasargumentsthatchieflydistinguisheswhichalgorithmsintheC++StandardLibrarycanbeusedwithwhichcontainerclasses.

Justaspointerscanbeusedinavarietyofwaysintraditionalprogramming,iteratorscanbeusedforanumberofdifferentpurposes.Aniteratorcanbeusedtodenoteaspecificvalue,justasapointercanbeusedtoreferenceaspecificmemorylocation.Apairofiteratorscanbeusedt

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 工程科技 > 电子电路

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2