简单的素数判断C程序
仅供学习使用:
/*********************************************
* Name : prime.c
* Purpose : prime (素数判断)
* Author : zimo
* Date : 01/21/2010
* ******************************************/
#include<stdio.h>
int main()
{
int m , n ;
printf("Enter a number: ");
scanf("%d",&n);
for (m = 2 ;m < n ;m++)
if (n % m ==0)
break;
if (m < n)
printf("%d is divisble by %d \n", n , m);
else
printf("%d is prime. \n",n);
return 0;
}
相关文档:
1.开发工具下载
TUBER C http://www.duote.com/soft/392.html
Turbo C 2.0 汉化版 http://www.programfan.com/showdown.asp?id=306
C-Free 4.0 http:/ ......
6000甚至10000,都可以,但大于6000,就开始滚屏了。。
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
int i,j,*f,tmp,c=0;
long int n,bits;
const double PI=2*asin(1.0),E=exp(1.0);
scanf("%ld",&n);
bits=(long)ceil(n*(log10(n)-log ......
找错题
试题1:
void test1()
{
char string[10];
char* str1 = "0123456789";
strcpy( string, str1 );
}
试题2:
void test2()
{
char string[10], str1[10];
int i;
for(i=0; i<10; i++)
{
str1[i] = 'a';
}
strcpy( string, str1 );
}
试题3:
void test3( ......
出于性能的考虑,标准c库中的某些函数是以宏的方式实现的。
大部分情况下这都是一个有益的方式,但是在跟踪或调试程序时,可能会使你产生困惑。
此时可以使用undef来避免这个问题。
例:
默认情况下
#include <ctype.h>
some code...
....
isspace ......