the algorithms episode one

来源:互联网 发布:高性能mysql 编辑:程序博客网 时间:2024/05/21 14:49

The following codes are dedicated to the research of integer, specially, to the prime number research.

#include "stdio.h"#define N 1000int main(){int i, j, a[N+1];for(a[1]=0,i=2;i<=N;i++)a[i]=1;for(j=2;j<=N/i;j++)a[i*j]=0;for(i=1;i<=N;i++)if(a[i])printf("%4d",i);printf("\n");system("pause");return 0;}
原创粉丝点击