- 1、本文档共11页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
编程 10(programming 10)
编程 10(programming 10)
91. write function fun, whose function is to calculate and output the sum of the square roots of the average of each of the two adjacent elements in a given array (length 9).
For example, the 9 elements in a given array are 12, 34, 4, 23, 34, 45,, 18, 3, 11 in turn, and the output should be.
#include stdio.h
#include math.h
Double fun (double x[9])
{int i;
Double, avg=0.0, sum=0.0;
For (i=0; i8; i++) {
Avg= (x[i]+x[i+1]) /2;
Sum+=sqrt (AVG);
}
Return sum;
}
92. write a function that calculates and outputs the variance of a given number of 10
S= Reagan (1/10* (Xk-x) and 2 (average 10 number)
Where x =1/10* sum (Xk)
For example, the given number of 10 is 95, 89, 76, 65, 88, 72, 85, 81, 90, 56, and.
#include stdio.h
#include math.h
Double fun (double x[10])
{int i;
Double, avg=0.0, sum=0.0, abs=0.0, fc;
For (i=0; i10; i++) sum+=x[i];
Avg=sum/10; / * * / average
For (i=0; i10; i++)
Abs+= (x[i]-avg) * (x[i]-avg);
Fc=sqrt (abs/10);
Return fc;
}
93. write function fun,
Its function is to compare the length of two strings (not to call the function of the string length provided by the C language), and the function returns a longer string. If the two strings are the same length, the first string is returned.
For example, type beijingCR Shanghai CR
The function returns shanghai.
#include stdio.h
Char *fun (char, *s, char, *t)
{int i;
Char, *p=s, *q=t;
For (i=0; *p *q; i++) {
P++; q++;
}
If (*p = 0 and *q = = 0) return s;
If (*p) return s;
Else return t;
}
94., please write function fun, its function is: calculate and output the following polynomial value: Sn=1+1/1, +1/2, +1/3, +1/4, +... .+1/n!
For example, in the main function, enter 15 from the keyboard to the N, and then the output is: s=2.718282.
#include stdio.h
Double fun (int n)
{double s=1; long t=1;
Int i;
For (i=1; i=n; i++)
{t=t*i; s+=1./t;}
Return s;
}
95. assume that the input string contains only letters and * numbers. Please write function fun, its function is: in addition to string pream
您可能关注的文档
- 结构陶瓷(Structural ceramics).doc
- 结石病小结(Nodule of lithiasis).doc
- 绕口令 大全 最全(The most complete tongue twister).doc
- 绘画的六项基础技能(The six basic skills of painting).doc
- 绘画艺术毕业论文(Graduation thesis of painting art).doc
- 给cpu降温(Cool the CPU).doc
- 给一个不窜货的理由(Give a reason to Cuanhuo).doc
- 给不按时吃饭的(For meals that are not on time).doc
- 给你的电子产品选件外套!(Give your electronic products an option coat!).doc
- 给儿子的一封信 by刘亚州(A letter to son by Liu Yazhou).doc
文档评论(0)