Write a C++/C function which prints out prime integers, i.e., given an input X, print out all its prime numbers. For example,
if X=20, prime elements will be: 1, 2, 3, 5, 7, 9, 11, 13, 17, 19.
If X= 100, primes are: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97.
void (int X)
{
???????
???????
}
Thanks.
A C++ interview question
所有跟帖:
•
Correction: 回复:A C++ interview question
-haomeili-
♀
(200 bytes)
()
07/17/2007 postreply
20:57:04
•
回复:1 is a prime number? I don't think so!
-鸡毛蒜皮-
♂
(0 bytes)
()
07/18/2007 postreply
11:19:35
•
这是一个数学问题,算法不难, 不像interview能遇到的
-MGM-
♂
(313 bytes)
()
07/17/2007 postreply
21:28:24
•
last line should be: if is_prime then print i
-MGM-
♂
(0 bytes)
()
07/17/2007 postreply
21:30:26
•
回复:A C++ interview question
-上中下-
♂
(370 bytes)
()
07/17/2007 postreply
22:16:54
•
"if round i/j=0, i=i-1, count=0;" 这里递减i的值是不对的
-MGM-
♂
(0 bytes)
()
07/17/2007 postreply
22:50:12
•
你数学怎么学的?!
-连续工作-
♀
(58 bytes)
()
07/18/2007 postreply
04:49:14
•
你这么凶把女孩子们都吓跑了...
-德州女孩-
♀
(0 bytes)
()
07/18/2007 postreply
06:49:26
•
你也强不到哪里去
-德州老外-
♂
(19 bytes)
()
07/18/2007 postreply
19:56:49