Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» NewBlueFx TotalFX Windows-FL | 1.11 GB
Tue Dec 17, 2013 12:42 pm by titquarra

» NewBlueFx TotalFX Windows-FL | 1.11 GB
Tue Dec 17, 2013 12:42 pm by titquarra

» Celebrity.Sex.Tape.UNCUT.&.UNRATED.2012.720p.BRrip.x264.YIFY.mp4
Tue Dec 17, 2013 8:32 am by titquarra

» Maya Autodesk Personal Learning Edition 8.5
Tue Dec 17, 2013 7:47 am by titquarra

» Tuyệt Kỹ Đong Giai Chân Kinh (tuyệt Kỹ cua trai)
Thu Aug 23, 2012 5:38 am by Admin

» Tuyệt kỹ cua giai
Thu Aug 23, 2012 5:36 am by Admin

» NETCAT.........
Mon Aug 13, 2012 6:35 am by Admin

» Bảo mật CSDL bằng phương pháp mã hóa.
Tue Apr 17, 2012 10:04 pm by Admin

» Hàm mã hóa MD5 bằng JavaScript
Tue Apr 17, 2012 10:03 pm by Admin

Shopmotion


Affiliates
free forum


giai thuat moi de tim day so nguyen to theo tu tuong cua Eratosthene

View previous topic View next topic Go down

giai thuat moi de tim day so nguyen to theo tu tuong cua Eratosthene

Post  Admin on Thu Jun 09, 2011 3:00 am

#include <conio.h>
#include <iostream.h>
#include <math.h>
void snt(int n){
int kt[1000];
kt[1]=0;
for(int i=2;i<=n;i++) kt[i]=1; //khoi tao kiem tra
int j; i=1;
while (i<=sqrt(n)){
while(kt[i+1]==0) i++;
i++;
for(j=i+1;j<=n;j++) if(j%i==0) kt[j]=0;
}
cout<<"\n";
for(i=2; i<=n;i++) if(kt[i]==1) cout<<i<<" "; //hien thi

}
void main(){
int n;
cout<<"\nn="; cin>>n;
snt(n);
getch();
}

Admin
Admin

Tổng số bài gửi : 782
Join date : 2009-08-15

View user profile http://hackis.forumotion.com

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum