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