求这个程序的算法流程图或者文字说明#include int main() {int prime(int);int n; printf("input an integer:");scanf("%d",&n);if (prime(n)) printf("%d is a prime.\n",n);else printf("%d is not a prime.\n",n);return 0;} int prime(int n){int
来源:学生作业帮助网 编辑:六六作业网 时间:2025/01/11 13:37:13
求这个程序的算法流程图或者文字说明#include int main() {int prime(int);int n; printf("input an integer:");scanf("%d",&n);if (prime(n)) printf("%d is a prime.\n",n);else printf("%d is not a prime.\n",n);return 0;} int prime(int n){int
求这个程序的算法流程图或者文字说明
#include int main()
{int prime(int);
int n;
printf("input an integer:");
scanf("%d",&n);
if (prime(n))
printf("%d is a prime.\n",n);
else
printf("%d is not a prime.\n",n);
return 0;
}
int prime(int n)
{int flag=1,i;
for (i=2;i
求这个程序的算法流程图或者文字说明#include int main() {int prime(int);int n; printf("input an integer:");scanf("%d",&n);if (prime(n)) printf("%d is a prime.\n",n);else printf("%d is not a prime.\n",n);return 0;} int prime(int n){int
#include <stdio.h>
int main( void )
{
int prime( int );
int n;
printf( "input an integer:" ); // 显示提示文本
scanf( "%d", &n ); // 读入输入的整数
if ( prime( n ) ) // 如果prime()返回真
printf( "%d is a prime.\n", n );
else // prime()返回假
printf( "%d is not a prime.\n", n );
return 0;
}
int prime( int n )
{
int flag = 1, i; // 标记初值设置为真
for ( i = 2; i < n / 2 && flag == 1; i++ ) // 测试因数从2到n/2,若标记不为真则提前结束
if ( n % i == 0 ) // 若n能被测试因数整除
flag = 0; // 置标记为假
return (flag); // 返回标记值
}