简单C语言编程(题目如下)
1个回答
展开全部
#include<stdio.h>
#include<math.h>
int judgeprimer(int innumber)
{
int count=2,flag=1;
for(count=2;count<=sqrt(innumber);count++)
if(innumber%count==0) {flag=0;break;}
return flag;
}
void main()
{
int innumber,flag;
printf("please enter a number you want to judge:");
scanf("%d",&innumber);
flag=judgeprimer(innumber);
if(flag) printf("innumber is a primer number.\n");
else printf("innumber is not a primer number.\n");
}
#include<math.h>
int judgeprimer(int innumber)
{
int count=2,flag=1;
for(count=2;count<=sqrt(innumber);count++)
if(innumber%count==0) {flag=0;break;}
return flag;
}
void main()
{
int innumber,flag;
printf("please enter a number you want to judge:");
scanf("%d",&innumber);
flag=judgeprimer(innumber);
if(flag) printf("innumber is a primer number.\n");
else printf("innumber is not a primer number.\n");
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询