3 Star 2 Fork 0

lo01/introduction_to_programming

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ex3_13.c 704 Bytes
一键复制 编辑 原始数据 按行查看 历史
JinxinDu 提交于 2022-05-06 11:33 . J.Du
// hello everyone, this is TD session 5 (WEEK 6)
// Today the exercises are 3.15, 3.13 and 4.4
// your task is to translate the algorithms (in pseudo-language) into C language
#include <stdio.h>
int Ex3_13() {
int n,i;
printf("enter a positive integer >1:\n");
scanf("%d",&n);
if(n==2)
printf("2 is a prime number\n");
else
{
if(n%2 ==0)
printf("this is not a prime\n");
else
{
i = 3;
while(i*i<n&&n%i!=0)
{
i = i+2;
}
}
if(i*i<=n)
printf("this is not a prime\n");
else
printf("this is a prime");
}
return 0;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lo01/introduction_to_programming.git
git@gitee.com:lo01/introduction_to_programming.git
lo01
introduction_to_programming
introduction_to_programming
master

搜索帮助