资源描述:
《c语言程序设计课件ppt(英文)c program language 之6 points and array》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、PointsandArrayXueQing2009.4Terms&arithmeticArray2-DarrayAddressPointerCallbyreferencePointerarrayGetmax(min)valueSortInsertDeleteStringcopyStringconectStringcomparisionPointsandArrayOnedimensionalArraysMultidimentsionalArraysPointersandAddressesPointersandFunctionArgu
2、mentsPointersandarrayCharacterPointersandFunctions&*array132Anarrayisadatatypethatusessubscripted(下标)variablesandmakespossibletherepresentationofalargenumberofhomogeneousvalues.InC,arraysandpointersarecloserelatedconcepts.Anarraynamebyitselfistreatedasaconstantpointer,andpointe
3、rs,likearrays,canbesubscripted.Stringsareone-dimensionalarraysofcharacters.1WhatisArrayinta[10]floata[30][5]OnedimensionalArraysIfyoudeclareinta,bc;therelationshipbetweena,b,c?Ifyoudeclareinta1,a2,a3……asthestudentsscore,thenumberofthegradesislarge,representingandmanipulatingthe
4、databymeansofuniqueidentifierswillbecumbersome.Howtogroupseveraldatawiththesametypetogether?ArrayThesametypeLimitednumbersStoreinsequenceOnedimensionalArrays2Howtodeclareaarray?Typearray-name[length]AllarraymembersarethesametypeAlso:size--Howmanyarraymembersinta[10]3Howtoaccess
5、arraymembers?NameandsubscriptFrom0tolenth-14Howtostorearraymembersinmemory?a[0]a[2]a[4]a[3]a[6]a[7]a[1]a[5]a[8]a[9]memoryStoreinsequencefromthefirstelementtothelastone.a[0]a[2]a[4]a[3]a[6]a[7]a[1]a[5]a[8]a[9]memory5Howtoinitializeanarray?inta[10]={1,2,3,4,5,6,7,8,9,0};floatx[5]
6、={1.9,2.0};inta[]={1,2,3,4};main(){inti,inta[10]={1,2,3,4,5,6,7,8,9,10};for(i=0;i<10;i++)printf(“%d,”,a[i]);}the1stsubscriptis0.OnedimensionalArraysmain(){inti,inta[10];for(i=0;i<10;i++)scanf(“%d”,&a[i]);for(i=0;i<10;i++)printf(“%d,”,a[i]);}OnedimensionalArraysAarraywith10membe
7、rs,findtheminimumanditssubscript,andtheninterchangeitsvaluewiththefirstmember.71332668153206512inta[10]71331682653206512a[0]a[i]a[9]Temporaryvariables:min,kSupposethefirstistheminimum:min=a[0],k=0Comparemintoeachmembersa[i],ifa[i]8、sgotothenextone.OnedimensionalArrays13<26min=a[1]k=126