编写一个函数,该函数的功能是判断一个整数是不是素数,

来源:百度知道 编辑:UC知道 时间:2024/05/22 10:50:19
编写一个函数,该函数的功能是判断一个整数是不是素数,在main函数
中输入一个整数,调用该函数,判断该数是不是素数,若是则输出“yes”,
否则输出“no”

我在线~~~急用!!!

#include<stdio.h>
int Simple(int n)
{
int i;
for(i=2;i<=n/2;i++)
if(n%i==0)break;
if(i>n/2)
return 1;
else
return 0;
}

void main()
{
int i,n;
scanf("%d",&n);
i=Simple(n);
if(i==1)
printf("yse");
else
printf("no");
}

#include <stdio.h>

void main()
{
int i = 0;
int n = 0;

printf("Please input n:");
scanf("%d", &n);
if ( n == 1 || n == 2 )
{
printf("yes\n");
}

for ( i = 2; i < n ; i++ )
{
if ( n % i == 0 )
{
printf("no\n");
break;
}
else if( i == n - 1 )
{
printf("yes\n");
}
}
return;
}

#include <stdio.h>
#include <math.h>

int iszhishu

编写一个函数该函数的功能是判断一个整数是不是素数,在主函数中调用该函数,输出200以内的所有的素数 14.请编写一个函数int fun(int x),它的功能是: 编写一个函数,返回三个数的平均值,并在主函数中调用这个函数,实现其功能。 编写函数实现字符串连接函数strcat()的功能。 编写一个 C 函数,该函数给出一个字节中被置1 的位的个数。 编写函数computNum( int num),它的功能是计算任意输入的一个正整数的各位数字之和,结果由函数返回。 编写一个排序函数,调用该函数,将经过排序后的数据在主调函数中输出。谢啦。 编写一个函数R(n),其功能是计算1+2+3+...+n的和,并且返回这个和。 编写一个C程序 其首部为int[chars[i]函数 功能是统计出字符,数组,中英文的个数 编写一个函数