当前位置:网站首页>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入门第一天完成
边栏推荐
- The problem of returning the longtext field in MySQL and its solution
- 微波雷达感应模块技术,实时智能检测人体存在,静止微小动静感知
- Tupu software digital twin | visual management system based on BIM Technology
- Is it safe for Guohai Securities to open an account online?
- HAC cluster modifying administrator user password
- 开源 SPL 消灭数以万计的数据库中间表
- Taishan Office Technology Lecture: from the layout height of the line, talk about the height overflow and height shrinkage of the drawing height (launched in the whole network)
- How to realize the Online timer and offline timer in the game
- 软件测试工程师是做什么的?待遇前景怎么样?
- 面试官:Redis 过期删除策略和内存淘汰策略有什么区别?
猜你喜欢
在线协作产品哪家强?微软 Loop 、Notion、FlowUs
Advanced application of C # language
Decision tree and random forest
#夏日挑战赛#数据库学霸笔记,考试/面试快速复习~
1亿单身男女撑起一个IPO,估值130亿
MMO项目学习一:预热
Fuzor 2020软件安装包下载及安装教程
Postman核心功能解析-参数化和测试报告
Go deep into the underlying C source code and explain the core design principles of redis
【历史上的今天】7 月 5 日:Google 之母出生;同一天诞生的两位图灵奖先驱
随机推荐
cf:B. Almost Ternary Matrix【對稱 + 找規律 + 構造 + 我是構造垃圾】
Notion 类生产力工具如何选择?Notion 、FlowUs 、Wolai 对比评测
Is the performance evaluation of suppliers in the fastener industry cumbersome? Choose the right tool to easily counter attack!
Android interview, Android audio and video development
块编辑器如何选择?印象笔记 Verse、Notion、FlowUs
[today in history] July 5: the mother of Google was born; Two Turing Award pioneers born on the same day
数据库 逻辑处理功能
100million single men and women supported an IPO with a valuation of 13billion
2022最新大厂Android面试真题解析,Android开发必会技术
Postman核心功能解析 —— 参数化和测试报告
The binary string mode is displayed after the value with the field type of longtext in MySQL is exported
MMO project learning 1: preheating
Ultrasonic ranging based on FPGA
Password reset of MariaDB root user and ordinary user
测试的核心价值到底是什么?
Fuzor 2020軟件安裝包下載及安裝教程
CF: B. almost Ternary Matrix [symétrie + règles de recherche + Construction + I am Construction Waste]
图扑软件数字孪生 | 基于 BIM 技术的可视化管理系统
JS解力扣每日一题(十二)——556. 下一个更大元素 III(2022-7-3)
PG基础篇--逻辑结构管理(用户及权限管理)