摘要: 思路:判断一个整数n是否为素数,只需用2到n-1之间的每一个整数去除,如果都不能被整除,那么m就是一个素数。判断定理:“n不能够被不大于根号n的任何素数整除,则n是一个素数”用代买表示如下:int is_prime = trure;int i = 2;while (i 2 #include 3 4 using namespace std; 5 6 int main() 7 { 8 int n; // Number to test for prime-ness 9 int i; // Loop counter10 int is_prime = true... 阅读全文
posted @ 2012-04-26 12:27 waynewuzhenbo 阅读(14674) 评论(0) 推荐(0) 编辑
摘要: C++ 运算符优先级列表 http://www.cppreference.com/operator_precedence.htmlPrecedenceOperatorDescriptionExampleAssociativity1()[]->.::++--Grouping operatorArray accessMember access from a pointerMember access from an objectScoping operatorPost-incrementPost-decrement(a + b) / 4;array[4] = 2;ptr->age = 3 阅读全文
posted @ 2012-04-26 08:48 waynewuzhenbo 阅读(818) 评论(0) 推荐(0) 编辑