当前位置:网站首页>acm入门day1
acm入门day1
2022-07-05 19:09:00 【ANYOUZHEN】
acm网址:【深基7.例2】质数筛 - 洛谷 洛谷网
题目描述:

源代码如下:
#include<stdio.h>
int main()
{
int n, i, j;
int sushu(int n);//定义一个判断素数的函数,如果为素数则返回m的值为1
int a[1000];
printf("please enter a number:");
scanf_s("%d", &n);
for (i = 0; i < n; i++)
scanf_s("%d", &a[i]);
for (i = 0; i < n; i++)
{
if (sushu(a[i]) == 1)
{
printf("%3d", a[i]);
}//输出素数
}
}
int sushu(int j)//素数函数
{
int i; int m;
for (i = 2; i < j; i++)
{
if (j % i == 0)
{
m = 0;
}
else
{
m = 1;
}
return m;
}
}运行成功:

acm入门第一天完成
边栏推荐
- How to convert word into PDF? Word to PDF simple way to share!
- After the company went bankrupt, the blackstones came
- 集合
- Debezium系列之:修改源码支持drop foreign key if exists fk
- JMeter 常用的几种断言方法,你会了吗?
- Go语言 | 03 数组、指针、切片用法
- You can have both fish and bear's paw! Sky wing cloud elastic bare metal is attractive!
- Applet modification style (placeholder, checkbox style)
- shell编程基础(第9篇:循环)
- Oracle fault handling: ora-10873:file * needs to be either taken out of backup or media recovered
猜你喜欢

大厂面试必备技能,2022Android不死我不倒

Go语言 | 03 数组、指针、切片用法

测试的核心价值到底是什么?

面试官:Redis中集合数据类型的内部实现方式是什么?

Go deep into the underlying C source code and explain the core design principles of redis

How to realize the Online timer and offline timer in the game

面试官:Redis 过期删除策略和内存淘汰策略有什么区别?

Word finds red text word finds color font word finds highlighted formatted text

Ten years at sea: old and new relay, dark horse rising

cf:B. Almost Ternary Matrix【对称 + 找规律 + 构造 + 我是构造垃圾】
随机推荐
大厂面试必备技能,2022Android不死我不倒
JAD installation, configuration and integration idea
Common interview questions in Android, 2022 golden nine silver ten Android factory interview questions hit
华为让出的高端市场,小米12S靠徕卡能抢到吗?
uniapp获取微信头像和昵称
100million single men and women supported an IPO with a valuation of 13billion
XaaS 陷阱:万物皆服务(可能)并不是IT真正需要的东西
决策树与随机森林
潘多拉 IOT 开发板学习(HAL 库)—— 实验8 定时器中断实验(学习笔记)
全网最全的低代码/无代码平台盘点:简道云、伙伴云、明道云、轻流、速融云、集简云、Treelab、钉钉·宜搭、腾讯云·微搭、智能云·爱速搭、百数云
PG基础篇--逻辑结构管理(用户及权限管理)
2022最新大厂Android面试真题解析,Android开发必会技术
出海十年:新旧接力,黑马崛起
The problem of returning the longtext field in MySQL and its solution
Technology sharing | interface testing value and system
Mariadb root用户及普通用户的密码 重置
HiEngine:可媲美本地的云原生内存数据库引擎
cf:B. Almost Ternary Matrix【对称 + 找规律 + 构造 + 我是构造垃圾】
Benefits of automated testing
IFD-x 微型红外成像仪(模块)关于温度测量和成像精度的关系