![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
Alex2013
这个作者很懒,什么都没留下…
展开
-
写文件时最好使用绝对路径, 而不使用相对路径
因为在程序中如果你使用如下方法写文件的话:std::ofstream out("cache.txt");out out.close();一般情况下, 它会写到当前应用程序所在目录, 但是如果在程序的某个地方, 调了SetCurrentDirectory原创 2011-09-01 13:12:39 · 1264 阅读 · 0 评论 -
http://projecteuler.net/problem=4 【参考解法】
#include using std::cout;using std::endl;typedef unsigned int uint32;const uint32 MIN = 99;const uint32 MAX = 999;uint32 revers_num(uint32 k){ uint32 rk = 0; while( k ) {原创 2011-11-26 02:18:25 · 303 阅读 · 0 评论 -
http://projecteuler.net/problem=1 [解法参考]
#include using std::cout;using std::endl;//sum of 1,2,...,nint sum( int n ){ if ( n < 1 ) { return 0; } return n * ( n + 1 ) /2;}int resolveP1( int m ){ int s3原创 2011-11-26 01:11:54 · 288 阅读 · 0 评论 -
http://projecteuler.net/problem=6 【参考解法】
#include #include using std::cout;using std::endl;//http://projecteuler.net/problem=6//The sum of the squares of the first ten natural numbers is,// 1^2 + 2^2 + ... + 10^2 = 385//The原创 2011-11-27 22:34:17 · 268 阅读 · 0 评论 -
http://projecteuler.net/problem=5【求解数组所有元素的最小公倍数】
两个数的最大公约数利用辗转相除法可以得到, 最小公倍数为乘积除以最大公约数。#include #include using std::cout;using std::endl;using std::vector;//返回两个数的最大公约数uint64_t gcd(uint64_t a, uint64_t b){ uint64_t tmp = b; //辗转相原创 2011-11-27 22:12:11 · 363 阅读 · 2 评论 -
http://projecteuler.net/problem=7 【求第10001个素数】
#include #include using std::cout;using std::endl;using std::vector;vector ivec;bool prime( uint32_t n ){ vector::iterator it = ivec.begin(); for ( it; it != ivec.end() && *it * *it原创 2011-11-27 23:01:48 · 336 阅读 · 0 评论 -
http://projecteuler.net/thread=8 [参考解法]
/*http://projecteuler.net/problem=8Find the greatest product of five consecutive digits in the 1000-digit number.7316717653133062491922511967442657474235534919493496983520312774506326239578318016原创 2011-11-29 01:52:07 · 335 阅读 · 1 评论 -
http://projecteuler.net/problem=9 【参考解法】
/*http://projecteuler.net/problem=9A Pythagorean triplet is a set of three natural numbers, a b c, for which,a^2 + b^2 = c^2For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2.There exists exactly one原创 2011-11-29 02:30:09 · 314 阅读 · 2 评论