Description: Count the number of prime numbers less than a non-negative number, n. Credits:Special thanks to @mithmatt for adding this problem and cre ...
分类:
其他好文 时间:
2016-03-31 07:03:33
阅读次数:
176
(A)控制流图 (B) 在if(isDivisible(primes[i],curPrime))里去掉isPrime=false,即可使t2比t1更容易发现。 (C) t=(n=1) (D) 节点覆盖: {1,2,3,4,5,6,7,8,9,10,11,12} 边覆盖: {(1,2),(2,10), ...
分类:
其他好文 时间:
2016-03-31 00:02:42
阅读次数:
174
a. 画出函数的控制流图 b. 设计一个t2=(n=5)能发现但t1=(n=3)不能发现的错误 如果这个函数的第22行 if (isDivisible(primes[i], curPrime))误写成了if (isDivisible(primes[0], curPrime)),即对以后的每个数是否是 ...
分类:
其他好文 时间:
2016-03-30 23:59:48
阅读次数:
378
题目的源代码如下: 问题: 1、以上源代码的控制流图如下: 2、当把下面判断是不是素数的代码中的for的条件改成for(int i = 0; i <= 0 ; i++)是代码如下 for(int i = 0; i <= 0; i++){ if(isDivisible(primes[i],curPri ...
分类:
其他好文 时间:
2016-03-30 19:27:04
阅读次数:
190
题目源程序 1 public static void printPrimes (int n) 2 { 3 int curPrime; // Value currently considered for primeness 4 int numPrimes; // Number of primes fo ...
分类:
其他好文 时间:
2016-03-30 06:52:14
阅读次数:
202
一、对一个方法进行测试 1)画出此方法的控制流图 2)T1 : n = 3 ;T2 : n = 5; 设计一个 Fault 使T2 能发现,T1不能发现: 答: 将 if ( isDivisible(primes[i],curPrime) 修改 为 if ( isDivisible(primes[0 ...
分类:
其他好文 时间:
2016-03-30 01:40:41
阅读次数:
234
中文书p49第7题 a-d a.画出控制流图 b.设计简单的错误,使测试用例t2 = (n=5)比t1 = (n=3)更容易被发现。 将if( isDivisible( primes[i], curPrime){ isPrime = false; break; }中的primes[i],改为prim ...
分类:
其他好文 时间:
2016-03-30 00:02:57
阅读次数:
215
注:质数从2开始,2、3…… 改进过程: 一、常规思路是对小于n的每一个数进行isPrime判断,isPrime(int x)函数中for(int i = 2; i <= x /2; ++i),如果x%i==0,return false。 二、将isPrime(int x)中i的范围改为i * i
分类:
其他好文 时间:
2016-03-20 17:35:59
阅读次数:
114
The first two consecutive numbers to have two distinct prime factors are: 14 = 2 × 7 15 = 3 × 5 The first three consecutive numbers to have three dist
分类:
其他好文 时间:
2016-03-07 10:10:09
阅读次数:
142
Count Primes:Count the number of prime numbers less than a non-negative number, n. 题意:求出小于n的数中质数的个数。 思路:可以先写出一个判断一个整数是否是质数的函数,然后在从1到n开始判断,但是通过不了,看了提示中...
分类:
其他好文 时间:
2016-03-05 20:28:08
阅读次数:
134