赞
踩
题目要求:如标题
思路:
以下是具体代码:
#include <stdio.h> int main() { void prime_number(int n); int a; printf("Please enter a number: "); scanf("%d",&a); prime_number(a); return 0; } void prime_number(int n) { int i; for(i=2;i<=n-1;i++) if(n%i==0) break; if(i==n) printf("%d is a prime number.\n",n); else printf("%d is not a prime number.\n",n); }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。