- 1、本文档共12页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
在线作业指针作函数参数用法(The online job pointer is used as function parameter)
在线作业指针作函数参数用法(The online job pointer is used as function parameter)
9.11 odd or even numbers in an array
Results: 100 / Discount: 0.8
Please make up a function fun (int, *a, int, N, *odd, int, *even, int). The function of the function is to find the sum of all odd numbers in the array, and the sum of all even numbers. The parameter n gives the number of data in the array: returns the sum of the odd numbers by using the pointer odd, and returns the sum of the even numbers by the pointer even.
For example: the values in the array are: 1, 8, 2, 3, 11, 6, and then use the pointer odd to return the odd numbers and 15; use the pointer even to return the even numbers and 16.
Part of the program source code is as follows.
#include stdio.h
#define N 20
Void, fun (int, *a, int, N, int, *odd, int, *even)
{int i;
*odd=*even=0;
For (i=0; in; i++)
If (a[i]%2==0)
*even=*even+a[i];
Else
*odd=*odd+a[i];
}
Int, main ()
{int, a[N], I, N, odd, even;
Scanf (%d, n);
For (i=0; in; i++)
Scanf (%d, a[i]);
Fun (a, N, odd, even);
Printf (The, sum, of, numbers:%d\n, odd, odd);
Printf (The, sum, of, number:%d\n, even, even);
Return 0;
}
Test input, expected output time limit, memory limit, extra process
Test case 1 shows 6 in text mode
1823116?
Display The, sum, of, odd, numbers:15 in text mode?
The, sum, of, even, number:16?
Unlimited 64M 0
9.12 floating points, four, five
Results: 100 / Discount: 0.8
Please make a function float fun (double, a, double, *h). The function of the function is to keep 2 decimal places for the value in the variable H, and to do four to five entries for third bits (the value in the H is positive).
For example, the H value is 8.32433, and the function returns 8.32;
The H value is 8.32533, and the function returns 8.33.
Part of the program source code is as follows.
#include stdio.h
Void fun (double, a, double, *h)
{int, B, c;
B= (int) (a*1000);
C=b%10;
If (c=5) b= (b-c+10) /10;
If (c5) b=b/10;
*h= (float) b/100;
}
Int, main ()
{
Double, a, h;
Scanf (%lf, a);
Fun (a,
您可能关注的文档
- 只问价格不问价值的文学时代(A literary age asking only price and no value).doc
- 叫水法(Water law).doc
- 可 米 路 贝 儿 四 色(Belle four-color comic way).doc
- 可以去记记的歌词(You can remember the lyrics).doc
- 可口可乐 成功(Coca-Cola success).doc
- 口译笔译分类词汇--体育运动词汇(Interpreting, translation, classification, vocabulary -- sports vocabulary).doc
- 可口可乐公司使命与战略目标(Mission and strategic objectives of Coca Cola Co).doc
- 可口可乐引导社会化营销(Coca-Cola leads social marketing).doc
- 可口可乐的面试题目(Coca-Cola interview questions).doc
- 可口麦田 巧克力朝圣之旅 畅享丝滑的幸福滋味(Delicious chocolate in the wheat fields; a pilgrimage trip; a silky happiness).doc
最近下载
- 广东省烟草专卖局(公司)招聘考试真题2024.docx
- 中小学校长专业发展的理论与演进模式.ppt VIP
- 2024年主任医师(正高)-血液病学(正高)考试历年高频考点题库含答案.docx VIP
- 2025年操作工技能考核考试-手工造型工笔试考试历年典型考题及考点含含答案.docx
- 我国药品管理动态及新法规解读-增补-2025执业药师继续教育答案.docx VIP
- DVD光头识别培训资料.pdf VIP
- 《初中生网络安全教育主题班课件》.ppt VIP
- 血液吸附技术在危重症中的应用.pptx VIP
- 2023年主任医师(正高)-血液病学(正高)考试历年真题集锦附带答案.docx VIP
- 八年级上册全部古诗词(18首).pdf VIP
文档评论(0)