- 1、本文档共12页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
在线作业指针作函数参数用法(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
文档评论(0)