当前位置:网站首页>Find all primes less than or equal to Lim, store them in AA array, and return the number of primes
Find all primes less than or equal to Lim, store them in AA array, and return the number of primes
2022-06-26 16:45:00 【Muzi..】
#include<stdio.h>
#include<stdlib.h>
#define MAX 100
int fun(int lim,int aa[MAX]);
int main()
{
int limit,i,sum;
int aa[MAX];
printf(" Enter a number :");
scanf("%d",&limit);
sum=fun(limit,aa);
for(i=0;i<sum;i++)
{
if(i%10==0&&i!=0)
printf("\n");
printf("%5d",aa[i]);
}
}
int fun(int lim,int aa[MAX])
{
int i,j,k=0;
for(i=2;i<=lim;i++)
{
for(j=2;j<i;j++)
{
if(i%j==0)
break;
}
if(j>=i)
{
aa[k++]=i;
}
}
return k;
}
边栏推荐
- 构造函数和析构函数
- Calculate the average of N numbers in the group indexed by the formal parameter x, move the data less than the average in the group indexed to the front of the array, and move the data greater than or
- C language -- legal identifier and integer
- [chat in 5] eight years after graduation, I have been pursuing my dream
- Kubecon China 2021 Alibaba cloud special session is coming! These first day highlights should not be missed
- Scala 基础 (二):变量和数据类型
- 【力扣刷题】二分查找:4. 寻找两个正序数组的中位数
- Solution for filtering by special string of microservice
- MS | Xie Liwei group found that mixed probiotics and their metabolites could alleviate colitis
- Detailed explanation of cookies and sessions
猜你喜欢
随机推荐
构造函数和析构函数
Calculate the sum of the main diagonals of the array
【毕业季】致毕业生的一句话:天高任鸟飞,海阔凭鱼跃
Qt 5.9.8 安装教程
Exquisite makeup has become the "soft power" of camping, and the sales of vipshop outdoor beauty and skin care products have surged
Make up the weakness - Open Source im project openim about initialization / login / friend interface document introduction
108. simple chat room 11: realize client group chat
[Li Kou brush question] monotone stack: 84 The largest rectangle in the histogram
100+ data science interview questions and answers Summary - basic knowledge and data analysis
牛客编程题--必刷101之动态规划(一文彻底了解动态规划)
In a bad mood, I just write code like this
What is the preferential account opening policy of securities companies now? Is it safe to open an account online now?
【力扣刷题】11.盛最多水的容器//42.接雨水
C language -- legal identifier and integer
Constructors and Destructors
Acid of redis
LeetCode Algorithm 24. 两两交换链表中的节点
进军AR领域,这一次罗永浩能成吗?
Knowing these commands allows you to master shell's own tools
day10每日3题(1):逐步求和得到正数的最小值









