c語言內部題庫(Clanguageinternalquestionbank)_第1頁
c語言內部題庫(Clanguageinternalquestionbank)_第2頁
c語言內部題庫(Clanguageinternalquestionbank)_第3頁
c語言內部題庫(Clanguageinternalquestionbank)_第4頁
免費預覽已結束,剩余31頁可下載查看

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

c語言內部題庫(Clanguageinternalquestionbank)Thefirstclassremovesormovestheasteriskassumethattheinputstringcontainsonlylettersand*numbers.Pleasewritefunctionfun,itsfunctionis:deletethetai1numberofthestringalldeleted,thefrontandmiddleofthe*numberisnotdeleted.Voidfun(char*a){while(*a!=‘、0')a++;A-;While(*a=='*')a--;*(a+1)='、0';)Change:[l]a2=k/10[2]returni;Fillin:[1]N[2]i[3]-lassumethattheinputstringcontainsonlylettersand*numbers.Pleasewritefunctionfun,itsfunctionis:inadditiontothestringleadingthe*number,thestringofother*deleteall.Voidfun(char*a){inti=0;char*p=a;While(*p&&*p=='*'){a[i]=*p;i++;p++;}While(*p){if(*p==*)){a[i]=*p;i++;}p++;}A[i]='\O';)Modification:[1]intk=0;[2]while(*p||*q)Fillin:[1]i[2]ps[j][3]tpassumethattheinputstringcontainsonlylettersand*numbers.Pleasewritefunctionfun,itsfunctionis:makethepreambleofthestringnumberisnotmorethanN;ifmorethanN,deleteredundantnumber;iflessthanorequaltoN,thendonothing,stringmiddleandtailofthenumberisnotdeleted.Forexample,ifthecontentinthestringis*******A*BC*DEF*G****,assumingthatthevalueofnis4,thenthecontentinthestringshouldbe****A*BC*DEF*G****.Voidfun(char*a,intn){inti=0,k=0;char*p,*t;P=t=a;While(*t==’*'){k++;t++;)If(k>n){while(*p){a[i]=*(p+k-n);i++;p++;}A⑴ハ〇,;})Modification:[1]t=l.0;[2]return(s*2);Fillin:[1][M][2]N[3],\0,assumethattheinputstringcontainsonlylettersand*numbers.Pleasewritefunctionfun,itsfunctionis:onlydeletestringleadingandtail*number,stringbetweentheletternumberisnotdeleted.Theparameterngivesthelengthofthestring,andtheparameterHgivesthenumberoftheleadingbitsinthestring,andtheparameteregivesthenumberofthelastnumberinthestring.Whenwritingfunctions,thestringfunctionprovidedbytheClanguagemustnotbeused.Forexample,ifthecontentinthestringis****A*BC*DEF*G*******,thenthecontentinthestringshouldbeA*BC*DEF*G.Voidfun(char*a,intn,inth,intE){inti,j=0;For(i=h;i<N-E;i++)a[j++]=a[i];A[j]='、0’;Modification:[1]fun(intx,inty,intz)[2]returnj;Fillin:[1]N[2]substr[3]0assumethattheinputstringcontainsonlylettersand*numbers.Pleasewritethefunctionfun,whosefunctionistomovealltheleadingnumbersinthestringtothetailofthestring.Voidfun(char*a){inti=0,n=0;char*p;P=a;While(*p=='*'){n++;p++;}While(*p){a[i]=*p;i++;p++;}While(n!=0){a[i]=n—};i++;*;A[i]='\0';Change:[1]s[j++]=s[i];[2]s[j]=‘、〇';Fillin:[l]a[2][3]score[i]pleasewriteafunctionvoidfun(char*ss),itsfunctionis:thestringSSallsubscriptforoddpositionlettersconvertedtouppercase(ifthelocationisnotletters,notconverted).Voidfun(char*ss){inti;For(i=0;ss[i];=‘、〇';i++){if(i%2==l&&ss[i]>='a'ss[i]く='z')Ss[i]=ss[i]-32;})Modification:[1]for(i=strlen(T);i>0;i一)[2]if(t[j]>t[j+1])Fillin:[l]k[2]N[3]a[k][i]Secondtypesofdatacombinationwritefunctionfun,Itsfunctionis:thetwotwodigitpositiveintegera,Bmergetoformaninteger,placedinC.ThemergingmethodisthatthetenbitsandthedigitsoftheanumberareplacedonthethousandsandtenbitsoftheCnumberinturn,andthetenbitsandthedigitsoftheBnumberareplacedonthehundredsandbitsoftheCnumberinturn.Forexample,whena=45,b=12,callthisfunction,c=4152.Voidfun(inta,intb,long*c){*c=(a/10)*1000+(b/10)*100+(a%10)*10+b%10;}Change:[1]for(i=0;i<sl;I+[2]t[2*sl]=‘、〇');Fillin:[1]STYPE[2]FILE[3]fpwritefunctionfun,itsfunctionis:thetwotwodigitpositiveintegera,Bmergetoformaninteger,placedinC.ThemergingmethodisthatthetenbitsandthedigitsoftheanumberareplacedonthehundredsandbitsoftheCnumberinturn,andthetenbitsandthedigitsoftheBnumberareplacedonthethousandsandtenbitsoftheCnumberinturn.Forexample,whena=45,b=12,callthisfunction,c=1425.Voidfun(inta,intb,long*c){*c=(b/10)*1000+(a/10)*100+(b%10)*10+a%10;}Modification:[1]intI,SI;[2]t[i]=s;Fillin:[l]0[2]x[3]t++writefunctionfun,itsfunctionis:thetwotwodigitpositiveintegera,Bmergetoformaninteger,placedinC.ThemergingmethodisthatthetenbitsandthedigitsoftheanumberareplacedonthehundredsandbitsoftheCnumberinturn,andthetenbitsandthedigitsoftheBnumberareplacedonthetenbitandthethousandbitoftheCnumbersequentially.Forexample,whena-45,b=12,callthisfunction,c=2415.Voidfun(inta,intb,long*c){*c=(b%10)*1000+(a/10)*100+(b/10)*10+a%10;}Modification:[1]char*fun(char(*sq)[M])[2]returnsp;Fillin:[1]structstudent*[2]a->score[3]awritefunctionfun,itsfunctionis:thetwotwodigitpositiveintegera,Bmergetoformaninteger,placedinC.Themergingmethodisthatthetenbitsandthedigitsoftheanumberareplacedonthebitsand100bitsoftheCnumberinturn,andthetenbitsandthedigitsoftheBnumberareplacedonthethousandsandtenbitsoftheCnumberinturn.Forexample,whena=45,b=12,callthisfunction,c=1524.Voidfun(inta,intb,long*c){*c=(b/10)*1000+(a%10)*100+(b%10)*10+a/10;}Modification:[1]voidfun(longs,long*t)[2]sl=sl*10;Fillin:[l]*fw[2]str[3]strwritefunctionfun,itsfunctionis:thetwotwodigitpositiveintegera,Bmergetoformaninteger,placedinC.Themergingmethodis:thetenbitandthenumberoftheanumberareplacedonthetenbitandthethousandbitoftheCnumberinturn,andthetenbitandthenumberoftheBnumberareplacedonthebitsandthehundredsoftheCnumberinturn.Forexample,whena=45,b=12,callthisfunction,c=5241.Voidfun(inta,intb,long*c){*c=a/10*10+a%10*l000+b/10+b%10*100}Modification:[1]voidfun(int(*a)[M],intm)⑵a[j][k]=(k+1)*(j+1);Fillin:[1]k[2]N[3]tempwritefunctionfun,itsfunctionis:thetwotwodigitpositiveintegera,Bmergetoformaninteger,placedinC.ThemergingmethodisthatthetenbitsandthenumberoftheanumbersareplacedonthetenandthousandbitsoftheCnumberinturn,andthetenbitsandthedigitsoftheBnumberareplacedonthehundredsandbitsoftheCnumberinturn.Forexample,whena=45,b=12,callthisfunction,c=5142.Voidfun(inta,intb,long*c){*c=(a%10)*1000+(b/10)*100+(a/10)*10+b%10;}Modification:[1]if(d%2==0)[2]s/=10;Fillin:[1]"R"[2]fs[3]ftwritefunctionfun,itsfunctionis:thetwotwodigitpositiveintegera,Bmergetoformaninteger,placedinC.ThemergingmethodisthatthetenbitsandthedigitsoftheanumberareplacedonthethousandsandtenbitsoftheCnumberinturn,andthetenbitsandthedigitsoftheBnumberareplacedonthebitsandthehundredsoftheCnumbersinturn.Forexample,whena=45,b=12,調用該函數后C=4251O空樂趣(int,int,長?){i,j?k,n;i=一%10;j=a/10;k=b%10;n=b/10;*=j*1000+k*100+i*10+n;}改:[1]國際娛樂(intn,intxx[M][M])[2]printf(“4D”,XX[我][J]);填:[1]1[2]的!=0[3]i*1014〇請編寫函數樂趣,其功能是:將兩個兩位數的正整數一、B合并形成一個整數放在C中。合并的方式是:將一數的十位和個位數依次放在C數的個位和百位上,B數的十位和個位數依次放在C數的十位和千位上。例如,當A=45,B=12,調用該函數后C=2514〇空樂趣(int,int,長?){=*(b%10)*1000+(一%10)*100+(b/10)*10+A/10;}改:[1]為(i=j+1;iくn;i++)[2],P=我;填:[1][2]關閉浮點(FP)[3]名第三類刪除指定位置字符15〇請編寫函數樂趣,其功能是:將的所指字符串中ASCH值為奇數的字符刪除,串中剩余字符形成一個新串放在T所指的數組中。例如,若的所指字符串中的內容為abcdefgl2345,其中字符一的ASCI!碼值為奇數、…字符1的ASCI!碼值也為奇數、…都應當刪除,其他依次類推。最后T所指的數組中的內容應是BDF24。虛空樂趣(char,char,[]){inti,j=0,n;N=strlen(s);為(i=0;i<;;+(+))如果((i)%2=0){t=ji];j++;)T="0”;)改:[1],(*W)[2]如果(R==XP)填:[1]的[我][2][3]“K0”16〇請編寫函數樂趣,其功能是:將的所指字符串中下標為偶數的字符刪除,串中剩余字符形成的新串放在T所指數組中。虛空樂趣(char,char,[]){inti,j=0,K=strlen(s);對于(i=1;i<;i=i+2)T(j);T=“〇”;改:[1]而(R)[2]*=*R;R+++;填:[1]數據[2]下的[3]頭17。請編寫函數樂趣,其功能是:將的所指字符串中除了下標為偶數、同時ASCII值也為偶數的字符外,其余的全都刪除;串中剩余字符所形成的一個新串放在T所指的數組中。例如,若的所指字符串中的內容為abcdefgl23456,其中字符一的ASCI!碼值為奇數,因此應當刪除;其中字符B的ASCI!碼值為偶數,但在數組中的下標為奇數,因此也應當刪除;而字符2的ASCII碼值為偶數,所在數組中的下標也為偶數,因此不應當刪除,其他依此類推最后所指的數組中的內容應是246to虛空樂趣(char,char,口){inti,j=0;為(i=0;s[i]!="0”;++)如果(i=2=0(2)=0);T="0”;}改:[I]=null;[2]如果(R==XP)填:[1]0[2]P>TE3]和民18。請編寫函數樂趣,其功能是:將的所指字符串中除了下標為奇數、同時ASCH值也為奇數的字符之外,其余的所有字符都刪除,串中剩余字符所形成的一個新串放在T所指的數組中。例如,若的所指字符串中的內容為abcdefgl2345,其中字符一的ASCII碼值雖為奇數,但所在元素的下標為偶數,因此必需刪除;而字符1的ASCH碼值為奇數,所在數組中的下標也為奇數,因此不應當刪除,其他依此類推最后所指的數組中的內容應是135to虛空樂趣(char,char,ロ){inti,j=0,n;n=strlen(s);for(i=0;i<n;i++)if(in%2!=0&&s[in]%2!=0){t[j]=s[i];j++;}t[j]='\O';}改:[1]voidfun(char*s,char*t)[2],t[2*d]='\〇';填:[1]3.0[2]>[3](2*1)19.請編寫ー個函數voidfun(chara[],charb[],intn)其功能是:刪除一個字符串中指定下標的字符.其中,a指向原字符串,刪除后的字符串存放在b所指的數組中,n中存放指定的下標.例如,輸入ー個字符串world,然后輸入3,則調用該函數后的結果為word.voidfun(chara[],charb[],intn){inti,k=0;for(i=0;a[i]!='、0';i++)if(!=n)bLk+]=a[i];b[k]='、0';)改:[1]while(fabs(t)>=num)[2]t=s/n;填:⑴t=[2]+2[3]'\0'第三類整除20.編寫函數fun,它的功能是:求出1到1000之內能被7或11整除、但不能同時被7和11整除的所有整數并將它們放在a所指的數組中,通過n返回這些數的個數.voidfun(int*a,int*n){inti,m=0;for(i=1;in<1000;i++)if(((%7==0)II(%11==0)&&!((%7==0)&&(%11==0))){a[m]=i;m+=1;}*n=m;改:[1]t=*x;*x=y;[2]return(t);填:[l]'s[in]⑵’9'[3]n.編寫函數fun,它的功能是:求n以內(不包括n)同時能被3與7整除的所有自然數之和的平方根s,并作為函數值返回.例如,若n為1000時,函數值應為s=153.909064.doublefun(intn){intsum;sum=0;for(i=0;i<n;i++){if(in%3==0&&i%7==0)sum=sum+;)return(sqrt(sum));)改:[1]if(k%13==0)II(k%17==0))[2]}填:[1]’〇'[2]s++[3]sum.請編寫ー個函數fun,它的功能是:求出1到m之內(含m)能被7或11整除的所有整數放在數組a中,通過n返回這些數的個數.例如,若傳送給m的值為50,則程序輸出:711142122283335424449voidfun(intm,int*a,int*n){inti,k;*n=0;for(i=1,k=0;inく=m;i++)if((x7==0)II(%11==0)){a[k+]=;(*n)++;}}改:[1]P=j;[2]p=;填:[1]q[2][3]syncsync第四類數組排序或矩陣23.請編寫ー個函數fun,它的功能是:找出ー維整型數組元素中最大的值和它所在的下標,最大的值和它所在的下標通過形參傳回.數組元素中的值已在主函數中賦予.主函數中x是數組名,n是x中的數據個數,max存放最大值,index存放最大值所在元素的下標.voidfun(inta[],intn,int*max,int*d){inti;*max=a[0];*d=0;for(i=0;i<n;i++)if(a[i]>*max){*max=a[i];*(d=;})改[1]:c++;[2]if(m==c)填:[1]1⑵2*[3]-1.請編寫ー個函數fun,它的功能是:求出ー個2Xm整型二維數組中最大元素的值,并將此值返回調用函數.fun(inta[][m]){inti,j,max=a[0][〇];for(i=0;i<2;i++)for(j=0,j<m;j++)if(max<a[i][j])max=a[i][j];returnmax;)改:[1]doublefun(intn)[2]s=s+(double)a/b;填:⑴3.0[2]>[3](2*1).請編寫ー個函數intfun(int*p,intt,int*k)?用來求出數組的最大元素在數組中的下標并存放在k所指的存儲單元中.例如,輸入如下整數:876675896101,301,401980431451777則輸出結果為:6980.intfun(int*p,intt,int*number){inti,max;max=s[0];for(i=0;i<t;i++)if(s[i]>max(max)=s[i];*k=i);)改:[1]t+=s[k];[2]*er=ave;填:[n+1]+[2I〇[3]s++.請編寫函數fun,該函數的功能是:實現b=a+a',即把矩陣a加上矩陣a的轉置,存放在矩陣b中.計算結果在main函數中輸出.voidfun(inta[3][3],intb[3][3]){inti,j;for(i=0;i<3;i++)for(j=0,j<3;j++)(b)[in][j]=a[i][j]+a[j],[in];)改:[1](i=2;inthe<=m;i++)[2],y+=1.0/(*);填:[1]&[2]''〇'[3]s[j]第五類通項公式求值27.請編寫ー個函數fun,它的功能是:根據以下公式求Ji的值(要求滿足精度0.0005,即某項小于0.0005時停止迭代):doublefun(doubleeps)double{s;thefloatn,t,pi;t=1;pi=0;n=1.0;p=1.0;while((fabs(s))>=eps){pi+=s;t=n/(2*n+1);s*=t;n++;}pi=pi*2;returnpi;改:[1]intfun(char*str,char*substr)for(i=0;str[i];i++)填:[0,1],[2]n[3](t*t).編寫函數fun,它的功能是:根據以下公式求p的值,結果由函數值帶回.m與n為兩個正整數且要求m>n.p=m!/n!(m-n)!.例如:m=12,n=8時,運行結果為495.000000.floatfun(intm,intn){inti,j,k;longintt=1,s=1,p=1;floatq;TOC\o"1-5"\h\zfor (i = 1; intheく= m;i + +) t* = in.for (j = 1; j < = n;j + +) s * =j;for (k = 1; k < = m-n; k++) p*=k;q= (float) t / s /p;returnq};改:[1],intj,c=0;floatxa=0.0;[2]if(x[j]>=xa)填:[1]*s[2]s++[3]n.編寫函數fun,函數的功能是:根據以下公式計算s,計算結果作為函數值返回;n通過形參傳入.s=1+1/(1+2)+1/(1+2+3)+...+1/(1+2+3+4+...+n),例如:若n的值為11時,函數的值為!.833333.floatfun(intn){inti,sum=1;floats=1;for(i=2;inthe<=n;i++){sum=sum+1;s=s+1.0/sum;}returns;}longchsdc(intn){inti,s;s=0;for(i=0;i<n;i++)s=s+i;return(s);改:[1]thedoublesum=0.0;[2]sum/=c;填:[1]'\〇’⑵0[3].編寫函數fun計算:s=(In(1)+In(2)+In(3)+...+In(m))0.5s作為函數值返回.在c語言中可調用log(n)函數求In(n).log函數的引用說明是:doublelog(doublex).例如,若m的值為20,則fun函數值為6.506583.doublefun(intm)double{(r);doubler,s;doublelog(double);for(i=1;inthe<=m;i++)r=r+log(i);return(sqrt((r));)改:[1]雙F(x)[2]返回的;填:[1]0[2][3]JJ3I〇請編寫函數樂趣,它的功能是:求斐波那契數列中大于T的最小的ー個數,結果由函數返回。其中斐波那契數列f(n)定義為:F(0)=0,F(1)=1,f(n)=F(n-1)+F(n-2)例如:當t=1000時,函數值為1597。趣味(整數T){inti,s=0;為(i=0;s;t;i+)s=f(i);返回的;)改:[1]S=S+(雙)(n+1)/n;[2]返回;填:[1],[2][3]0個32〇編寫函數樂趣,它的功能是:計算并輸出下列級數和:S=1/1*2+1/2*3+…+1/n(n+1)例如,當n=10時,函數值為0.909091。雙重樂趣(整數N){intI;雙s=0;對于(i=1;i=n;i++)s=l/(i*(i+1));返回的;改:[1]浮樂趣(intk)[2]返回的;填:[1]的[2][3][1]Kn33〇編寫函數樂趣,它的功能是:利用以下所示的簡單迭代方法求方程cos(x)x=〇的ー個實根。程序將輸出結果根=0.739085c浮fun(){浮動X0,XI=0;做{x0=xl;XI=cos(x0);}而(晶圓廠(x0-xl)>le-006);返回xl;)改:[1],((高)=2)和(N<10))[2]是=0;突破;填:[1]我++[2][3]MM34c請編寫函數樂趣,它的功能是計算下列級數和,和值由函數值返回。例如,當n=10,x=0.3時,函數值為1.349859。雙重樂趣(雙x,intn){ii:浮點p=l;長q=l;雙T,s=l;對于(i=l;i=n;i+);;返回的;)改:[1]雙重樂趣(intn)[2]收起回復;我填:[1][2][3][J]PSTP第六類指定字符的統計和字符串處理35。請編寫ー個函數樂趣,它的功能是:比較兩個字符串的長度,(不得調用C語言提供的求字符串長度的函數),函數返回較長的字符串。若兩個字符串長度相同,則返回第一個字符串。例如,輸入:北京上海〈cr>(くcr>為回車鍵),函數將返回上海。字符?(字符集,字符集){;當((*SS)和(*)TT){+++;};};}如果(*)返回(t);其他返回(s);改:[1]voidfun(char*)[2]printf("%c"*);填:[1]Tー>下[2]的ー)數據[3]T36〇編寫ー個函數樂趣,它的功能是:實現兩個字符串的連接(不使用庫函數strcaい,即把所指的字符串連接到P1P2所指的字符串后。例如,分別輸入下面兩個字符串:FirstString,secondstring;則程序輸出:FirstStringSecondString虛空樂趣(char,[]){inti,j;對于(i=0;Pli;i+);對于(j=0;P2[j];j++);Pl“i=”0;)改:[1]*T=0;[2]如果(D%2!=0)填:[1]0[2]XX10[3]n/1037〇請編寫函數樂趣,它的功能是:求出SS所指字符串中指定字符的個數,并返回此值。例如,若輸入字符串輸入字符123412132,1,3則輸出。趣味(字符集,字符C){int=0;當(*)!="〇"){如果(*SS=〇;+;+;+;);}返回(數字);)改:[1]for(J=I+1,J<6;J++)[2]*(*pstr+i)=(pstr+j);填:[1][2]+J+S[I][I]=tl[3]IくJ.請編寫ー個函數voidFun(char*tt,int[PP]),統計在字符串中到‘‘to'Z'26個字母各自出現的次數,并依次放在pp所指數組中.例如,當輸入字符串abcdefgabcdeabc后,程序的輸出結果應該是:3332211000000000000000000〇.VoidFun(char*tt,int[PP]){inti;For(i=0;I<26;I++)pp[I]=0;For(;*tt,TT++if()く=TT**TT&&'Z'=>'')pp*tt[97]++;改:[1]longS=0,T=0;[2]t=T/10;填N-1:[1]⑵[3][k]C.請編寫ー個函數fun,它的功能是:將一個數字字符串轉換為ー個整數(不得調用c語言提供的將字符串轉換為整數的函數).例如,若輸入字符串“1234”,則函數把它轉換為整數值ー1234.LongFun(char*p)LongS={0,T;Inti=0,J=strlen(n,P,K,SI);If(P=[0]=I++'」);For(J=I;J<=N-1,J++){T=P[j]-'0';SI=10;For(k=J;K<N-1;K++)T*=SI;S+=t;}If(P=[0]='-'Return(S);Elsereturns;改:[1]if(n==0)[2]result*=N填:[1][2][3]x0第七類素數.編寫函數fun,其功能是:將所有大于1小于整數m的非素數存入xx所指數組中,非素數的個數通過k傳回.例如,若輸入17,則應輸出:9和46891012141516.VoidFun(intm,int*K,intXX[]){inti,J;*k=0;For(i= 2;I < m; I++)For(J= 2;J < I; J++)If(1%j =xx = 0) {[(k)] =I++;break;}}[1]if((TT[I]=>'')(TT&&[I]く='Z')[2][I]-TT=32;填M:[1][2][3]K請編寫ー個函數voidFun(intm,intK,intXX[]),該函數的功能是:將大于整數m且緊靠m的k個素數存入xx所指的數組中.例如,若輸入:17.5,則應輸出:19,23,29,31,37.本題中的for循環用來判斷ー個數是否為素數,由于個數只能是k個所以用do-while循環來控制.VoidFun(intm,intK,intXX[]){inti,J=0,p=M+1;OJ{for(i=2;I<p;I++)if(P==0%i)break;If(i=P)xx[j]=P++++;P;}while(J<k);改:[1]DoubleFun(intn)[2]s=S+(double)/B;填:[1][2]-[3]return0第ハ類結構體(學生分數)學生的記錄由學號和成績組成,n名學生的數據已在主函數中放入結構體數組s中,請編寫函數fun,它的功能是:把分數最低的學生數據放在h所指的數組中,注意:分數最低的學生可能不止ー個,函數返回分數最低的學生的人數.IntFun(strecstrec*,B*){inti,J=0,n=0,min;Min=a[0].S;For(i=0;I<n;I++)If(a[I]s<min)min=a[I]s;For(i=0;I<n;I++)If(a[I]=MIN{s=)*(B+j)=a[I];J++++};n;Return;}改:[1]if(P==n)return-1;[2]a[I]=a[I+1];StructStudent填:[1][2][3]a.score[I]Mpersonalresultsstoredinthescorearray,pleasewritefunctionfun,itisthefunctionis:belowtheaveragenumberofpeopleasafunctionvaluetoreturn,willbebelowtheaveragescoreplacedinthebelowreferstothearray.Forexample,whenthedatainthescorearrayis10,20,30,40,50,60,70,80,90,thenumberoffunctionsreturnedshouldbe4,andthedatainbelowshouldbe10,20,30,40.Thefirstfortotalcirculationisusedtocalculatethefractionofscoreinthearray,andthenuseaver/=mtocalculatetheaveragevalueofsecondcyclestofindlessthantheaveragepointsandelementsinthearraybelow,hereweshouldpayattentiontoincreasingJ.Intfun(intscore[],intm,intbelow[]{inti,j=0,aver=0;For(i=0;i<m;i++)aver+=score[i];Aver/=m;For(i=0;i<m;i++)If(score[i]<aver)below[j++]=score[i];ReturnJ;}Modification:[1]for(i=2;iく=m;i++)[2]y-=1.0/(i*i);Fillin:[l]i[2]0[3]i++pleasewriteafunctionfun,itsfunctionis:calculatetheNgatecourseaverage,calculationresultsasfunctionvaluereturn.Forexample,iftheresultsof5coursesare:90.5,72,80,61.5,55,thefunctionvalueis71.80.Floatfun(float*a,intn){floatav=0.0;inti;For(i=0;i<n;i++)av=av+a[i];Return(av/n);Change:[1]longk=l;[2]num/=10;Fillin:[l]x[2]p[3]sstudents,recordsarecomposedofstudentnumbersandgrades.ThedataofNstudentshasbeenputintothestructurearraysinthemainfunction.Pleasewritethefunctionfun.Itsfunctionistoarrangethestudents'recordsaccord

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論