锘??xml version="1.0" encoding="utf-8" standalone="yes"?>久久精品国产久精国产果冻传媒 ,精品久久久久久国产,久久精品国产亚洲av影院http://m.shnenglu.com/cxl82116/category/4084.html錛?+緇嗚妭娣卞害鎺㈢儲鍙婅蔣浠跺伐紼?/description>zh-cnTue, 20 May 2008 09:17:10 GMTTue, 20 May 2008 09:17:10 GMT60姹傛湁搴忓簭鍒楀叕鍏遍儴鍒?闆嗗悎浜ら泦鐨凮(n)澶嶆潅搴︽眰娉?http://m.shnenglu.com/cxl82116/archive/2008/01/15/41228.html灝忛緳鍝?/dc:creator>灝忛緳鍝?/author>Tue, 15 Jan 2008 13:12:00 GMThttp://m.shnenglu.com/cxl82116/archive/2008/01/15/41228.htmlhttp://m.shnenglu.com/cxl82116/comments/41228.htmlhttp://m.shnenglu.com/cxl82116/archive/2008/01/15/41228.html#Feedback0http://m.shnenglu.com/cxl82116/comments/commentRss/41228.htmlhttp://m.shnenglu.com/cxl82116/services/trackbacks/41228.html闃呰鍏ㄦ枃

]]>
綺劇偧寰幆鍙崇Щhttp://m.shnenglu.com/cxl82116/archive/2007/05/15/24132.html灝忛緳鍝?/dc:creator>灝忛緳鍝?/author>Tue, 15 May 2007 02:03:00 GMThttp://m.shnenglu.com/cxl82116/archive/2007/05/15/24132.htmlhttp://m.shnenglu.com/cxl82116/comments/24132.htmlhttp://m.shnenglu.com/cxl82116/archive/2007/05/15/24132.html#Feedback1http://m.shnenglu.com/cxl82116/comments/commentRss/24132.htmlhttp://m.shnenglu.com/cxl82116/services/trackbacks/24132.html闃呰鍏ㄦ枃

]]>
Some algorithms about judging a prime .http://m.shnenglu.com/cxl82116/archive/2007/04/19/22266.html灝忛緳鍝?/dc:creator>灝忛緳鍝?/author>Wed, 18 Apr 2007 19:05:00 GMThttp://m.shnenglu.com/cxl82116/archive/2007/04/19/22266.htmlhttp://m.shnenglu.com/cxl82116/comments/22266.htmlhttp://m.shnenglu.com/cxl82116/archive/2007/04/19/22266.html#Feedback6http://m.shnenglu.com/cxl82116/comments/commentRss/22266.htmlhttp://m.shnenglu.com/cxl82116/services/trackbacks/22266.html
1.GRIDDLE METHOD (ALSO CALLED SIFT METHOD)

When I was a student in Bachelor phrase , a teacher has tought me a method called griddle method , it's principle is:

if a number can be devided by another number(except 1) , it isn't a prime , so , we set the non-prime at zero. after all number [In fact , half of the range checked is OK ]test finished , We simply output the NON-ZERO number , it 's the prime table in the RANGE.

E.G
Define the Range from 1-100;
/********************************************************************
 created: 2007/04/19
 created: 19:4:2007   3:00
 filename:  C:\testvc6\TestStll\TestStll.cpp
 file path: C:\testvc6\TestStll
 file base: TestStll
 file ext: cpp
 author:  Chang xinglong(King.C)
 purpose: Print Prime Table in RANGE(1-100)
*********************************************************************/

The Code Here :

 


#include 
<iostream>
#include 
<algorithm>
#include 
<vector>
using namespace std;

void InitArray(int A[] ,int len)
{
    
for (int i=0;i<len;i++)
    
{
        A[i]
=i+1;
    }

}


void OutputPrime(int A[] ,int len)
{
  
for (int i=2;i<len;i++)
  
{
      
for (int j=2;i*j<=len;j++)
      
{
          A[i
*j-1]=0;
          cout
<<i<<","<<j<<","<<i*j<<endl;
      }

     
  }

  
for (i=0;i<len;i++)
  
{
      
if (A[i]!=0)
      
{
          cout
<<A[i]<<" ";
      }

      
  }

  cout
<<endl;
}

// Main Method [4/19/2007 Changxinglong (King.C)]
int main(int argc, char* argv[])
{
    
int A[100];
    InitArray(A,
100);
    OutputPrime(A,
100);
    
return 1;
}




 2.THE DIRECT METHOD

E.G

/********************************************************************
 created: 2007/04/19
 created: 19:4:2007   3:00
 filename:  C:\testvc6\TestStll\TestStll.cpp
 file path: C:\testvc6\TestStll
 file base: TestStll
 file ext: cpp
 author:  Chang xinglong(King.C)
 purpose: Prime ?
*********************************************************************/

Here is the Kernel Function(Quote : STL TURORIAL REFERRENCE):

 

 1//predicate, which returns whether an integer is a prime number
 2bool isPrime (int number)
 3{
 4//ignore negative sign
 5number = abs(number);
 6// 0 and 1 are prime numbers
 7if (number == 0 || number == 1{
 8return true;
 9}

10//find divisor that divides without a remainder
11int divisor;
12for (divisor = number/2; number%divisor != 0--divisor) {
13;
14}

15//if no divisor greater than 1 is found, it is a prime number
16return divisor == 1;
17}


In Main Function , traverse the given range judge every number use the above function:

int main(int argc , char * argv[])
{
  
int A[100];
  InitArray(A,
100);
  
for(int i=0;i<100;i++)
    
if(isPrime(A[i]))
       cout
<<A[i]<<endl;
}

3. Extention
 Further , if  there is a given List or Vector and it's filled with data , how can you find the prime number in the data effiectly ?
STL Algorithm can help you indeed. After the step two , we can write a few code to implement the function:
int main()
{
list
<int> coll;
//insert elements from 1 to 100
for (int i=1; i<=100++i) {
coll.push_back(i);
}

//search for prime number
list<int>::iterator pos;
pos 
= find_if (coll.begin(), coll.end(), //range
isPrime); //predicate
if (pos != coll.end()) {
//found
cout << *pos << " is first prime number found" << endl;
}

else {
//not found
cout << "no prime number found" << endl;
}

}




]]>
How can you efficeny judge whether the num is primer?http://m.shnenglu.com/cxl82116/archive/2007/04/19/22265.html灝忛緳鍝?/dc:creator>灝忛緳鍝?/author>Wed, 18 Apr 2007 18:39:00 GMThttp://m.shnenglu.com/cxl82116/archive/2007/04/19/22265.htmlhttp://m.shnenglu.com/cxl82116/comments/22265.htmlhttp://m.shnenglu.com/cxl82116/archive/2007/04/19/22265.html#Feedback0http://m.shnenglu.com/cxl82116/comments/commentRss/22265.htmlhttp://m.shnenglu.com/cxl82116/services/trackbacks/22265.html
There is a easy way to do it , the follow code isn't written by me  but  a classic method

E.G quote from STL tutorial reference
#include <iostream>
#include 
<list>
#include 
<algorithm>
#include 
<cstdlib> //for abs()
using namespace std;
//predicate, which returns whether an integer is a prime number
bool isPrime (int number)
{
//ignore negative sign
number = abs(number);
// 0 and 1 are prime numbers
if (number == 0 || number == 1{
return true;
}

//find divisor that divides without a remainder
int divisor;
for (divisor = number/2; number%divisor != 0--divisor) {
;
}

//if no divisor greater than 1 is found, it is a prime number
return divisor == 1;
}




]]>
久久精品亚洲中文字幕无码麻豆| 狠狠色丁香久久综合婷婷| 一本久久久久久久| 亚洲国产精品久久| 亚洲国产成人久久一区久久| 国产精品中文久久久久久久| 久久综合国产乱子伦精品免费| 国产亚洲精久久久久久无码| 久久国产成人精品国产成人亚洲| 人妻少妇精品久久| 99久久精品国内| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 亚洲精品无码久久不卡| 久久精品国产99国产精品导航| 久久精品亚洲日本波多野结衣| 国产99久久九九精品无码| av色综合久久天堂av色综合在 | 久久久久久曰本AV免费免费| 国内精品久久久久久99| 漂亮人妻被中出中文字幕久久| 精品久久777| 久久综合亚洲欧美成人| 精品国产乱码久久久久软件| 亚洲伊人久久大香线蕉苏妲己| 亚洲精品无码专区久久久| 青青青青久久精品国产h久久精品五福影院1421 | 久久亚洲国产精品123区| 国产精品久久永久免费| 伊人久久综合无码成人网| 日日狠狠久久偷偷色综合96蜜桃 | 久久人人爽人人澡人人高潮AV| 91精品国产91久久综合| 国产A级毛片久久久精品毛片| 欧美午夜A∨大片久久| 久久久久亚洲AV成人网人人网站| 国内精品久久国产大陆| 99国产精品久久久久久久成人热| 免费精品久久天干天干| 7777精品伊人久久久大香线蕉| 超级碰碰碰碰97久久久久| 噜噜噜色噜噜噜久久|