当前位置:网站首页>(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;
}
边栏推荐
- Flink learning 6: programming model
- ModStartBlog 现代化个人博客系统 v5.2.0 源码下载
- RHCSA 01 - 创建分区与文件系统
- Application scheme of Puyuan ds1000z series digital oscilloscope in communication principle experiment
- ROS2中CMake编译选项的设置
- Emlog user registration plug-in is worth 80 yuan
- NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
- Kivy教程之 更改背景颜色(教程含源码)
- Dry goods | detailed explanation of webshell Foundation
- Keysight n9320b RF spectrum analyzer solves tire pressure monitoring scheme
猜你喜欢

十字路口通行优先权,十字路口通行规则图解

Keysight N9320B射频频谱分析仪解决轮胎压力监测方案

旭化成首次参展第五届中国国际进口博览会(5th CIIE)

RPC技术

Kivy教程之 更改背景颜色(教程含源码)

Experience sharing of epidemic telecommuting | community essay solicitation

FT2000+下LPC中断绑核使用说明

Redis: order collection Zset type data operation command

Architecture training graduation design + summary

Leetcode skimming: binary tree 07 (maximum depth of binary tree)
随机推荐
Krypton saikr daily question - CTF
Kivy教程之 自定义字体(教程含源码)
北漂程序员,月薪20K,一年攒15W,正常吗?
[Yugong series] go teaching course 002 go language environment installation in July 2022
Why use node
NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
Pytest basic self-study series (I)
Leetcode skimming: binary tree 04 (sequence traversal of binary tree)
Instructions for LPC interrupt binding under ft2000+
ROS2中CMake编译选项的设置
Experience sharing of epidemic telecommuting | community essay solicitation
[microservice openfeign] @feignclient detailed explanation
Longest increasing subsequence problem (do you really know it)
【愚公系列】2022年7月 Go教学课程 001-Go语言前提简介
戳气球和布尔运算问题(巨难)
(指针)编写函数void fun(int x,int *pp,int *n)
Asahi Kasei participated in the 5th China International Import Expo (5th ciie) for the first time
EventBridge 在 SaaS 企业集成领域的探索与实践
博朗与Virgil Abloh于2021年为纪念博朗品牌100周年而联合打造的“功能性艺术”将在博物馆展出Abloh作品期间首次亮相
新手找陪驾要注意什么