The seventh question of Homwork4--graphcoverage

Source: Internet
Author: User

/******************************************************* * Finds and prints n prime integers * Jeff Offutt, SPR ING 2003 ******************************************************/      Public Static voidPrintprimes (intN) {intCurprime;//Value currently considered for primeness        intNumprimes;//Number of primes found so far.        BooleanIsPrime;//Is curprime prime?        int[] primes =New int[Maxprimes];//The list of prime numbers. //Initialize 2 into the list of primes.primes [0] = 2; Numprimes= 1; Curprime= 2;  while(Numprimes <N) {curprime++;//next number to consider ...IsPrime =true;  for(inti = 0; I <= numPrimes-1; i++)             { //For each previous prime.                if(curprime%primes[i]==0)                 { //Found a divisor, curprime is not prime.IsPrime =false;  Break;//Out of loop through primes.                }             }             if(isprime) {//Save It!Primes[numprimes] =Curprime; Numprimes++; }         } //End while//Print all the primes out.         for(inti = 0; I <= numPrimes-1; i++) {System.out.println ("Prime:" +Primes[i]); }     } //End Printprimes

Title Code as above, Method printprimes ()

(a) Control flow graph

(b) When an array out-of-bounds error occurs, it is easier to consider test case t1= (n=3) and t2= (n=5) at this time T2 than T1 to find errors.

(c) It is possible to pass the while loop when N=1.

(d)

Node overwrite: {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}

Side overlays: {(2,3), (2,12), (3,4), (4,5), (5,6), (5,9), (6,7), (6,8), (8,9), (7,5), (9,10), (9,11) (The 10,11), (11,2), (12, 13), (13,14), (14,13), (13,15)}

Main path Overrides:

[1,2,3,4,5,6,7] ;

[1,2,3,5,6,8,9,11];

[1,2,3,5,6,8,9,10,11];

[1,2,3,5,9,11];

[1,2,3,5,9,10,11];

[1,2,12,13,14];

[1,2,12,13,15];

[3,4,5,6,8,9,10,11,2,12,13,14];

[3,4,5,6,8,9,10,11,2,12,13,15];

[3,4,5,6,8,9,11,2,12,13,14];

[3,4,5,6,8,9,11,2,12,13,15];

[3,4,5,9,11,2,12,13,15];

[3,4,5,9,11,2,12,13,14];

[3,4,5,9,10,11,2,12,13,15];

[3,4,5,9,10,11,2,12,13,14];

[6,9,5,9,11,2,12,13,15];

[6,9,5,9,11,2,12,13,14];

[6,9,5,9,10,11,2,12,13,15];

[6,9,5,9,10,11,2,12,13,14];

[14,13,15];

[2,3,4,5,6,8,9,11,2];

[2,3,4,5,6,8,9,10,11,2];

[2,3,4,5,9,11,2];

[2,3,4,5,9,10,11,2];

[13,14,13];

[5,6,7,5];

The seventh question of Homwork4--graphcoverage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.