赞
踩
一、N-S流程图;
二、运行结果;
三、源代码;
- # 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;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。