标签:return printf enter with for ESS number scanf cond
读入整数,判断是否为素数
程序核心——for语句、break语句
#include<stdio.h>
int main()
{
int i,m;
printf("Enter a nmber:");
scanf("%d",&m);
for(i=2;i<=m/2;i++)
if(m%i==0)
break;
if(i>m/2&&m!=1)
printf("%d is a prime number!\n",m);
else
printf("NO");
return 0;
}
Enter a nmber:9
NO
--------------------------------
Process exited after 4.596 seconds with return value 0
请按任意键继续. . .
重点:break语句跳出循环、判断
标签:return printf enter with for ESS number scanf cond
原文地址:https://www.cnblogs.com/5236288kai/p/10660779.html