当前位置:网站首页>C language: find all integers that can divide y and are odd numbers, and put them in the array indicated by B in the order from small to large
C language: find all integers that can divide y and are odd numbers, and put them in the array indicated by B in the order from small to large
2022-06-25 08:45:00 【zbossz】
First , Let's study the criteria for odd numbers ( How to decide if it is an odd number ):
Let's first analyze 10 An odd number within
1 3 5 7 9
We found that , they %2 all =1
So the criteria for odd numbers are %2!=0.
Next we just need to traverse + Just make a decision
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#define size 20
void fun(int y, int b[], int* m)
{
int i = 0;
int j = 0;
while (i < size)
{
if (i % y == 0 && i % 2 != 0)
{
b[j] = i;
*m += 1;
j++;
}
i++;
}
}
int main()
{
int y = 3, m = 0;
int b[size] = {
0};
fun(y, b, &m);
printf("%d\n", m);
int i = 0;
while (b[i] != '\0')
{
printf("%d ", b[i]);
i++;
}
return 0;
}


边栏推荐
- Lvs-dr mode multi segment case
- Problems caused by Gil problems and Solutions
- Stack awareness - stack overflow instance (ret2libc)
- How to solve the 10061 error of MySQL in Linux
- 声纹技术(一):声纹技术的前世今生
- 想要软件测试效果好,搭建好测试环境是前提
- How to calculate the positive and negative ideal solution and the positive and negative ideal distance in TOPSIS method?
- 软件测试月薪10K如何涨到30K,只有自动化测试能做到
- 买股票通过客户经理的开户二维码开户资金是否安全?想开户炒股
- 声纹技术(二):音频信号处理基础
猜你喜欢

浏览器查看当前页面所有的监听事件
![[515. find the maximum value in each tree row]](/img/0d/7ae494a5b3df3917ab95ebf61a1c96.png)
[515. find the maximum value in each tree row]

Incluxdb time series database

How is the ISM model analyzed?

What are the indicators of VIKOR compromise?

第五天 脚本与UI系统

atguigu----17-生命周期

About i/o -- the relationship between memory and CPU and disk

《树莓派项目实战》第五节 使用Nokia 5110液晶屏显示Hello World

C language "recursive series": recursive implementation of 1+2+3++ n
随机推荐
Various synchronous learning notes
City Chain technology platform, really Realizing value Internet reconstruction!
Getting to know the generation confrontation network (11) -- using pytoch to build wgan to generate handwritten digits
openid是什么意思?token是什么意思?
检测点是否在多边形内
Hyper-v:Hyper-v 第 1 代或第 2 代虚拟机
Easyplayer streaming media player plays HLS video. Technical optimization of slow starting speed
What does openid mean? What does "token" mean?
Meaning of Jieba participle part of speech tagging
城链科技平台,正在实现真正意义上的价值互联网重构!
Object.defineProperty也能监听数组变化?
IC研发常用英文术语缩写
【515. 在每个树行中找最大值】
How to calculate the distance between texts: WMD
软件工程复习题
初识生成对抗网络(12)——利用Pytorch搭建WGAN-GP生成手写数字
Trendmicro:apex one server tools folder
Check whether the point is within the polygon
声纹技术(四):声纹识别的工程部署
Wechat applet_ 7. Project practice, local life