一、N-S流程图;
二、运行结果;
三、源代码;
cs
# define _CRT_SECURE_NO_WARNINGS
# include <stdio.h>
int main()
{
//初始化变量值;
int n = 0;
int i = 0;
int result = 0;
//提示用户;
printf("请输入大于3的整数n的值:");
//获取用户输入的值;
scanf("%d", &n);
//循环运算判断;
for (i = 2; i < n; i++)
{
//运算;
result = n % i;
//判断;
if (result == 0)
{
//跳出循环;
break;
}
}
//判断;
if (result == 0)
{
//输出结果;
printf("%d不是质数!!!!\n", n);
}
else
{
//输出结果;
printf("%d是质数!!!!\n", n);
}
return 0;
}