当前位置:网站首页>(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;
}
边栏推荐
- AcWing第 58 场周赛
- 多位科技公司创始人向Entrepreneur First提供高达1.58亿美元的C轮融资,协助其投资下一代全球创新者
- Unity draws the trajectory of pinball and billiards
- Architecture practice camp - graduation project of module 9 of phase 6
- 牛客小白月赛49
- 分布式CAP理论
- 博朗与Virgil Abloh于2021年为纪念博朗品牌100周年而联合打造的“功能性艺术”将在博物馆展出Abloh作品期间首次亮相
- NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
- B. All Distinct
- RHCSA 06 - suid, sgid, sticky bit(待补充)
猜你喜欢
随机推荐
DP83848+网线热拔插
Select function variable column name in dplyr of R language
FT2000+下LPC中断绑核使用说明
博朗与Virgil Abloh于2021年为纪念博朗品牌100周年而联合打造的“功能性艺术”将在博物馆展出Abloh作品期间首次亮相
[microservice openfeign] @feignclient detailed explanation
(指針)自己寫一個比較字符串大小的函數,功能與strcmp類似。
MIN_RTO 对话
Leetcode brush question: binary tree 06 (symmetric binary tree)
Balloon punching and Boolean operation problems (extremely difficult)
“找工作不要太在意工资”,这是我听过最大的谎言
dried food! Generation of rare samples based on GaN
R语言中如何查看已安装的R包
leetcode:1314. 矩阵区域和【二维前缀和模板】
牛客小白月赛49
Unity draws the trajectory of pinball and billiards
Touch your hand and bring you a commonjs specification
新手找陪驾要注意什么
UnicodeDecodeError: ‘gbk‘ codec can‘t decode byte 0x98 in position 1093: illegal multibyte sequence
【愚公系列】2022年7月 Go教学课程 001-Go语言前提简介
Use NRM and NVM to manage your NPM source and node versions









