当前位置:网站首页>简单的素数程序 初学者 希望码龄高的大佬可以一下
简单的素数程序 初学者 希望码龄高的大佬可以一下
2022-07-26 22:38:00 【沉梦昂志浮生若梦】
#include <stdio.h>
int main()
{
int k;
void prime(int k);
int flag = 1;
char ch;
while(flag)
{
printf("输入一个数判断他是否为素数");
scanf_s("%d", &k);
prime(k);
printf("输入N结束判断否则继续");
getchar();
ch=getchar();
if (ch == 'N' || ch == 'n')
flag = 0;
}
}
void prime(int k)
{
int i;
for (i = 2; i <= k / 2; i++)
if (k % i == 0)
{
printf("%d is not prime", k);
break;
}
else if(i==k/2)
printf("%d is prime", k);
}
边栏推荐
猜你喜欢

Shufflenet series (2): explanation of shufflenet V2 theory

5_线性回归(Linear Regression)

01 knapsack problem 416. Segmentation and equal sum subset -494. Goal and

三层架构 模拟

Convolutional neural network -- lenet (pytorch Implementation)

Matlab based medical imaging technology filtering backprojection simulation, including direct backprojection, S-L filtering, R-L filtering, LeWitt filtering

13_集成学习和随机森林(Ensemble Learning and Random Forests)

蒙着头配置deeplabcut 1

Three tier architecture simulation

滑动窗口问题总结
随机推荐
机器学习模型——lightGBM
LeetCode题目——二叉树篇
AutoCAD的卸载后重新安装,删除注册表的详细过程
AlexNet(Pytorch实现)
Uni app learning (II)
TypeScript(tsconfig.json)
100. Same tree
9_ Logistic regression
Xshell连接服务器时报“Could not load host key”错误
放图仓库-3(功能图像)
Codeforces D. Buying Shovels
Apple TV HD with the first generation Siri remote is listed as obsolete
20220720 toss deeplobcut2
Configure deeplobcut2 with your head covered
Helicopter control system based on Simulink
4-4 object lifecycle
5_线性回归(Linear Regression)
Deploy yolov5 error reporting in pycharm
Tree and binary tree (learning notes)
RecBole使用1