当前位置:网站首页>(pointer) write function void fun (int x, int *pp, int *n)
(pointer) write function void fun (int x, int *pp, int *n)
2022-07-04 04:35:00 【I'm not Xiao Haiwa~~~~】
function : Find out x Even factor of , And put them in the order from small to large pp In the array referred to , The number of these factors is determined by formal parameters n return ( hypothesis pp Point to enough space ).
Such as :x by 24
Then six numbers meet the requirements ,2、4、6、8、12、24 All saved to pp in n by p
Code:
void fun(int x,int *pp,int *n)
{
*pp=0;
*n=0;
int cnt=0;
for(int i=2;i<=x;i++)
{
if(x%i==0)
{
if(i%2==0)
{
if(*pp==0)
{
pp[cnt++]=i;
(*n)++;
}
else if(i>pp[--cnt])
{
cnt++;
pp[cnt++]=i;
(*n)++;
}
}
}
}
}
int main()
{
int aaa[100]={
0};
int ss=0;
fun(512,aaa,&ss);
for(int i=0;i<ss;i++)
{
cout<<aaa[i]<<endl;
}
return 0;
}
边栏推荐
- Keysight n9320b RF spectrum analyzer solves tire pressure monitoring scheme
- B. All Distinct
- How to add custom API objects in kubernetes (1)
- Wechat official account infinite callback authorization system source code
- Flink learning 7: application structure
- Unity资源路径
- 5张图告诉你:同样是职场人,差距怎么这么大?
- [Yugong series] go teaching course 001 in July 2022 - Introduction to go language premise
- Use NRM and NVM to manage your NPM source and node versions
- 浅谈一篇优质的小红书文案需要具备什么
猜你喜欢

Imitation of "game bird" source code, mobile game issue evaluation, open service, open test collection, game download website template

Exercises in quantum mechanics

Flink learning 6: programming model

【微信小程序】好看的轮播图组件

Flink learning 7: application structure

96% of the collected traffic is prevented by bubble mart of cloud hosting

【愚公系列】2022年7月 Go教学课程 001-Go语言前提简介
![[microservice openfeign] @feignclient detailed explanation](/img/8d/83bcde1355366c7c88a7a9ade7f9eb.png)
[microservice openfeign] @feignclient detailed explanation

多位科技公司创始人向Entrepreneur First提供高达1.58亿美元的C轮融资,协助其投资下一代全球创新者

NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
随机推荐
Leetcode brush question: binary tree 06 (symmetric binary tree)
RHCSA 04 - 进程管理
What is the difference between Western Digital Green disk, blue disk, black disk, red disk and purple disk
Touch and take you to implement an EventEmitter
陪驾注意事项 这23点要注意!
牛客小白月赛49
Why use node
Rhcsa 06 - suid, sgid, sticky bit (to be added)
(pointer) write a function to compare the size of strings by yourself, which is similar to StrCmp.
(指針)自己寫一個比較字符串大小的函數,功能與strcmp類似。
A beautiful API document generation tool
The five pictures tell you: why is there such a big gap between people in the workplace?
Leetcode brush questions: binary tree 05 (flip binary tree)
RHCSA 07 - 用户与群组管理
浅谈一篇优质的小红书文案需要具备什么
Exploration and practice of eventbridge in the field of SaaS enterprise integration
更优雅地远程操作服务器:Paramiko库的实践
架构训练毕业设计+总结
ROS2中CMake编译选项的设置
Unity draws the trajectory of pinball and billiards