您可能感兴趣的话题: CodeBlocks入门教程 编码方块
核心提示:fortran编程如何判断素数
【创建fortran工程】





【编写代码】
program main
implicit none
integer::a,i,flag
flag=1
read *,a
do i=2,a-1
if(mod(a,i)==0)then
flag=0
exit
end if
end do
if(flag==1)then
print *,a,"是素数"
else
print *,a,"不是素数"
end if
end
【在codeblocks中编译、链接】

【运行、测试结果】
