当前位置:网站首页>(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;
}
边栏推荐
- Precautions for accompanying driving these 23 points should be paid attention to!
- 分布式CAP理论
- Redis: operation command for collecting set type data
- 【安全攻防】序列化与反序列,你了解多少?
- 批处理初识
- 浅谈JVM的那些事
- Modstartblog modern personal blog system v5.2.0 source code download
- 虚拟商品帐号交易平台源码_支持个人二维码收款
- NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
- Flink learning 7: application structure
猜你喜欢
Asahi Kasei participated in the 5th China International Import Expo (5th ciie) for the first time
[cloud native] those lines of code that look awesome but have a very simple principle
Redis: operation command for collecting set type data
FT2000+下LPC中断绑核使用说明
5张图告诉你:同样是职场人,差距怎么这么大?
Unity draws the trajectory of pinball and billiards
Boutique website navigation theme whole station source code WordPress template adaptive mobile terminal
leetcode:1314. 矩阵区域和【二维前缀和模板】
普源DS1000Z系列数字示波器在通信原理实验中的应用方案
Wechat official account infinite callback authorization system source code
随机推荐
EventBridge 在 SaaS 企业集成领域的探索与实践
十字路口通行优先权,十字路口通行规则图解
2020 Bioinformatics | TransformerCPI
A beautiful API document generation tool
Exercises in quantum mechanics
Kivy教程之 格式化文本 (教程含源码)
2021 RSC | Drug–target affinity prediction using graph neural network and contact maps
Deep parsing structured exception handling (SEH) - by Matt Pietrek
Instructions for LPC interrupt binding under ft2000+
Keysight N9320B射频频谱分析仪解决轮胎压力监测方案
DP83848+网线热拔插
Architecture training graduation design + summary
Longest increasing subsequence problem (do you really know it)
leetcode:1314. Matrix area and [2D prefix and template]
tdk-lambda电源主要应用
RHCSA 07 - 用户与群组管理
One click compilation and deployment of MySQL
两万字带你掌握多线程
分布式CAP理论
Leetcode skimming: binary tree 04 (sequence traversal of binary tree)