c语言题库答案(Clanguageexamanswer)

上传人:缘*** 文档编号:333289103 上传时间:2022-09-01 格式:PDF 页数:52 大小:2.45MB
返回 下载 相关 举报
c语言题库答案(Clanguageexamanswer)_第1页
第1页 / 共52页
c语言题库答案(Clanguageexamanswer)_第2页
第2页 / 共52页
c语言题库答案(Clanguageexamanswer)_第3页
第3页 / 共52页
c语言题库答案(Clanguageexamanswer)_第4页
第4页 / 共52页
c语言题库答案(Clanguageexamanswer)_第5页
第5页 / 共52页
点击查看更多>>
资源描述

《c语言题库答案(Clanguageexamanswer)》由会员分享,可在线阅读,更多相关《c语言题库答案(Clanguageexamanswer)(52页珍藏版)》请在金锄头文库上搜索。

1、c 语言题库答案(C l a n g u a g e e x a m a n sw e r)1.given N data,calculating the minimum value of the position(if the minimum value appeared repeatedly,calculate theposition can appear for the first time)Int i,k;K=0;For(i=l;in;i+)If(sisk)k=i;Return(K);The maximum value of third i=n for five k+12.program

2、 for E and the output value of the irrational number.The calculation formula is as follows:E=l+1/1!+1/2!+1/3!+.1/n.!When 1/n =0.000001)(E=e+j c;J=l;Fo r (k=l;k =i;k+)J=j*k;J c=l.0/j;I+;)Re tu r n e;3.f o r a n u m be r o f m a x i m u m a n d m i n i m u m v a l u e o f th e p r o d u c t.Int i,Max,

3、min;Max=min=aO;For(i=l;lmax)max=ai;Else if(ai=5)Return(int)(h*100+l)/100.0;ElseReturn(int)(h*100)/100.0;5.input from the keyboard on any real number x,calculate thecorresponding value functionZ=(x-4)twoEight to the power of z=x(x-4)Z=4/(x*(x+1)(x-10)Z=|x|+20(other)Answer:Float z;If(x4)z=(x-4)*(x-4);

4、Else if(x-4)z=pow(x,8);Else if(x-10)z=4/(x*(x+1);Else z=fabs(x)+20;Return(Z);6.calculate line coordinate and column coordinate of themaximum element array and the N*M plastic(if the maximumelement is not only the choice of location in the front one).For example,the output array:12341561218910112The

5、maximum number is calculated for 18,for 2 coordinate,coordinates for the 1.columnInt max,I,j;Max=array 0 0;Row=0;Col=0;For(i=0;iN;i+)for(j=0;jM;j+)If(max0)d=n%10;S*=d;N/=10;Return s;An average of 8.n calculation course value,calculated as afunction return value.For example:if 5 course grades are:92,

6、76,69,58,88,thef u n c ti o n v a l u e i s 76.599998I n t i;浮 y =0;为(i =0;i n;i+)y +=一个 我;Y =Y /N;回到Y;9O求一批数中小于平均值的个数。i n t i,总和=0,K =0;浮动平均;为(i =0;i n;i+)金额=金额+一个 我;平均=金额*1.0/n;为(i =0;i 一个 我)K +;返 回(K);10o编写函数判断一个整数M的个位数字之和能否被7整除,可以被7整除则返回1,否则返回0。调用该函数找出100 200之间满足条件的所有数。i n t k,s=0;做 S =S +M%10;M

7、 =M /10;而(M!=0);如 果(S%7=0)K =1;其他K =0;返 回(K);H o 请编一个函数 v o i d f u n (i n t T T M 的,为 P P),T T指向一个M行N列的二维数组,求出二维数组每列中最大元素,并依次放入所指一维数组中二维数组中的数已在主函数中赋予P P。i n t i,j;为(J =0;J P P J )P P J =T T 我 J ;1 2 o编写函数乐趣用比较法对主程序中用户输入的具有10个数据的数组一按由大到小排序,并在主程序中输出排序结果。i n t k,j,t;为(k =0;K n-1;K +)为(J =k +1;Jn;j+)如

8、果(数组k 数组J )T =阵 打;阵列 K=阵列 J L;数组J =T;)13o 编写主要程序调用函数事实求解从M个元素选N 个元素的组合数的个数。计算公式是:组合数=M!/(N!(M-N)!)o要求:M不能小于N,否则应有容错处理。说明:函数事实(x)的功能是求X!而(m n)(p r i n tf (M 和 N 输入错!请重新输入:/N );sc a n f (“d%d”,与 M 和 N);z h sg s=事 实(M)/(事 实(N)*事 实(M-N);1 4o找出一批正整数中的最大的偶数。i n t i,A M A X =一个0 ;为(i =0;i A M A X A M A X =

9、一个 我个;收益最大;1 5o实现两个整数的交换。例如:给一和B分别输入:60和6 5,输出为:a 65 b=60i n t t;T =*;*a *b;*B=T;16oT h e str i n g i n th e c o r r e sp o n d i n g l o w e r c a se l e tte r s c o n v e r te d tou p p e r c a se l e tte r s,a n d o th e r c h a r a c te r s r e m a i n u n c h a n g e d.I n t i;For(i=0;stri=0;i+

10、!)If(str i=,a and str i 0)d=n%10;S+=d*d*d;N/=10;)Return s;The number 18.for a group of the number is greater than theaverage number of.For example:a given number is 1,3,6,9,4,23,35,67,12,88,thefunction value is 3.Int i,k=0;Float s=0,ave;For(i=0;in;i+)S+=ai;Ave=s/n;Printf(%f,ave);For(i=0;iave)k+;Reet

11、urn k;19.for any number of X,with the following formula and theoutput value of Y.5 x10Answer:Int m;If(n=10)M=-5;Else m=0;Else m=5;Return m;20.for a given positive integer less than m prime and.Answer:Int i,K,s=0;For(i=2;i=m;i+)for(k=2;ki;k+)If(i%k=0)break;If(k=i)s=s+i;Return s;21.to determine whethe

12、r x is an integer number ofisomorphism.Less than 100.Int k;K=x*x;If(k%10=x)|(k%100=x)Return 1;ElseReturn 0;22.functions for integer N on a 10,60 is divisible by 5Int i;For(i=0;im)M=arri;23.write the function fun for sum=d+dd+ddd+.Long int s=0,t=0;Int i;For(i=l;i=n;i+)t=t+d;S=s+t;D=d*10;)Return s;24.

13、write the function fun will be an array of values storedin reverse order.Int i,t;For(i=0;in/2;i+)t=arri;Arri=arr;A r r n-l-i =t;25.to 8 c h a r a c te r s i n l e n g th o f th e str i n gi n o r d e r to.I n t i,j;Ch a r t;Fo r (i=0;i n u m;i+)Fo r (j=i+l;j n u m;j+)I f (s i s j )t=s i ;s i =s j ;s

14、 j =t;2 6 o根据整数参数N,计算如图公式的值浮动=1;i n t i;为(i =1;i n;i+)=1/(1 +);返回一个;270键盘上输入一个3行3列矩阵出并 在f u n()函数中输i n t 和;i n t i,j;总和=1 ;为(i =0;i 3;i+)金额=金额*我 的 我;收起回复;28 o编写函数乐趣(S T R,I,N),连续N个字符而(S T R 我+n-1 )=S T R S T R 我+n-1 ;我+;S T R =0”表示;29o 统计出若干个学生的平均成绩,最高分人数i n t i;浮总和=0,大道;马克斯=阵0 ;为(i=0;i n;i+)如果(马克斯

15、数组 我)m a x=数组 我;金额=金额+阵列 我;大道=总和/N;为(i =0;i n;i+)如 果(数组 我=m a x)J+;返 回(A V E);3 0 o 编写程序,实现矩阵(3 行 3 歹 U)的转置i n t i,j,t;为(i =0;i 3;i+)为(J=0;J(我;j+)T =数组J 我;数组 我J=数组J 我;数组J 我=T;3 1 o 用函数实现字符串的复制.i n t i;为(i =0;s t r l 的 我!=为 ;i+)出现 我=s t r l 的 我;出现 我=0”;3 2O从键盘为一维整型数组输入1 0 个整数,.IN T MIN,我;m i n =x 0 ;

16、为(i =1;i n;i+)i f (x 我 分钟)分钟=x 我;返回m i n;3 3 o 用做而语句求1-1 0 0 的累积和i n t i =1,总和=0;做 金额=金额+我;我+;而(我 =n);收起回复;3 4 o编写函数求1-1 0 0 奇数的平方和浮 S =0;i n t i,j;为(i =1;i n;1 =1 +2)S =S +我*我;返 回(S);3 5 o 计算并输出给定整数的所有因子之积不大于5 0 的长 S =1,我;为(i=2;i =n;i+)如 果。%我=0)S =S *我;返回的;3 6 o 求 1 T 0 0 之间的偶数之积双 Y =1;i n t i ;为(i =1;i =m;i+)如 果(n%2 =0)Y *=我;回至U Y ;3 7O编写函数球表达式的和(N的值的)1 /2.浮S =0;i n t i,k=1;为(i =1;i W n;i+)S =S +K*1.0/i;K=K;返 回(S);3 8o 产生 2 0个 3 0 1 2 0 .i n t i,j,s;S =一个0 0 ;为(i =0;i 5;i+)为(J=0;J =2)&(b 0)S =

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 商业/管理/HR > 营销创新

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号