当前位置:网站首页>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;
}
边栏推荐
- Stm32h7b0 replaces the h750 program, causing the MCU to hang up and unable to burn the program
- 108. simple chat room 11: realize client group chat
- 建立自己的网站(16)
- Redis 迁移(操作流程建议)
- C语言 头哥习题答案截图
- Detailed explanation of cookies and sessions
- pybullet机器人仿真环境搭建 5.机器人位姿可视化
- Solution for filtering by special string of microservice
- [from database deletion to running] JDBC conclusion (finish the series in one day!! run as soon as you finish learning!)
- I regard it as a dry product with a monthly income of more than 30000 yuan for sidelines and more than 10000 yuan for novices!
猜你喜欢
JS教程之使用 ElectronJS、VueJS、SQLite 和 Sequelize ORM 从 A 到 Z 创建多对多 CRUD 应用程序
Kubecon China 2021 Alibaba cloud special session is coming! These first day highlights should not be missed
Cloud platform monitoring system based on stm32+ Huawei cloud IOT design
[from database deletion to running] JDBC conclusion (finish the series in one day!! run as soon as you finish learning!)
Supplement the short board - Open Source im project openim about initialization / login / friend interface document introduction
Interpretation of cloud native microservice technology trend
stm32h7b0替代h750程序导致单片机挂掉无法烧录程序问题
对话长安马自达高层,全新产品将在Q4发布,空间与智能领跑日系
Scala 基础 (二):变量和数据类型
Stm32h7b0 replaces the h750 program, causing the MCU to hang up and unable to burn the program
随机推荐
进军AR领域,这一次罗永浩能成吗?
心情不好,我就这样写代码
《软件工程》期末重点复习笔记
[understanding of opportunity -31]: Guiguzi - Daoyu [x ī] Crisis is the coexistence of danger and opportunity
[learn FPGA programming from scratch -46]: Vision - development and technological progress of integrated circuits
proxy
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
day10每日3题(1):逐步求和得到正数的最小值
Memory partition model
基於Kubebuilder開發Operator(入門使用)
数据分析----numpy快速入门
108. 简易聊天室11:实现客户端群聊
Redis 概述整理
I regard it as a dry product with a monthly income of more than 30000 yuan for sidelines and more than 10000 yuan for novices!
当一个程序员一天被打扰 10 次,后果很惊人!
Toupper function
Niuke Xiaobai monthly race 50
【毕业季】致毕业生的一句话:天高任鸟飞,海阔凭鱼跃
C语言 头哥习题答案截图
stm32h7b0替代h750程序导致单片机挂掉无法烧录程序问题