每天进步一点!每天离梦想靠近一点!
to_zoe_yang · 共 109 篇文章
Problem 7
问题描述: By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10001st prime number? public static boolean IsPrime(long number) { int begin = 2; int end = (int) Math.sqrt(number) + 1; for (int i = begin; i < end; i++) { if (number % i == 0) re…
2011-06-13 20:37 · 算法 · 评论(0)
Problem 6
问题描述: The sum of the squares of the first ten natural numbers is, 12 + 22 + ... + 102 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)2 = 552 = 3025 Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3…
2011-06-13 20:27 · 算法 · 评论(0)
Problem 5
问题描述: 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? 求出1~20的最小公倍数. 思路如下: //辗转相除法求最大公倍数 public long count_gcd(long a, long b){ long big = a>b …
2011-06-13 20:06 · 算法 · 评论(0) · ITeye
Problem 3
问题描述: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? 找出一个数字的最大因子。 public static boolean IsPrime(long number) { int begin = 2; int end = (int) Math.sqrt(number) + 1; for (int i = begin; i < end; i++) { if (number % i == 0) return false; …
2011-06-12 20:22 · 算法 · 评论(1)
Problem 4
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99. Find the largest palindrome made from the product of two 3-digit numbers. 找到满足一下两个条件的数 1.回文数 2.由两个三位数相乘可得 //判断是否是回文数 public static boolean is_palindrome(int number){ S…
2011-06-12 19:17 · 算法 · 评论(0)
Problem2
问题描述 Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the ev…
2011-06-12 17:57 · 算法 · 评论(0)
天气小工具
昨天我们得到了全国的省份,市,区的三级信息。我们就应该让用户能选择。 [img]http://dl.iteye.com/upload/picture/pic/92082/36563b95-55ae-3e8d-8aef-b9e420141d53.bmp[/img] [img]http://dl.iteye.com/upload/picture/pic/92084/210e09e9-0ac9-3537-9fda-815f43d69595.bmp[/img] [img]http://dl.iteye.com/upload/picture/pic/92086/25a50380-5e4b-38a4-b…
2011-06-12 15:37 · Java相关 · 评论(0) · ITeye
Problem 1
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. public int Counnt1(){ int result = 0; int begin =3; int end = 1000; long t1 = System.currentTimeMillis(); for(int…
2011-06-11 21:26 · 算法 · 评论(0)
自己做个天气小工具
自己的手机上下了个天气工具,感觉非常棒!自己就想实现一下! 目前的想法就是从提供天气信息的网站上获得相关信息并提取! http://www.weather.com.cn/ 这个网站提供的天气信息非常好,格式也非常符合标准! 信息抓取工具:HttpWatcher 装好HttpWatcher后,在网页中启动HttpWatcher,在IE中输入http://www.weather.com.cn/,并选中一个城市,闭关会抓取网页信息。 这个就不详述了。。。 通过对抓取到的信息的分析,得到一个城市的天气的网页URL为http://www.weather.com.cn/weather/101190101…
2011-06-11 16:35 · Java相关 · 评论(0) · 正则表达式 · ITeye · IE
JAVA中的字符集
【IT168技术文档】 Unicode是一种字符编码规范 。 先从ASCII说起。ASCII是用来表示英文字符的一种编码规范,每个ASCII字符占用1个字节(8bits) 因此,ASCII编码可以表示的最大字符数是256,其实英文字符并没有那么多,一般只用前128个(最高位为0),其中包括了控制字符、数字、大小写字母和其他一些符号 。 而最高位为1的另128个字符被成为“扩展ASCII”,一般用来存放英文的制表符、部分音标字符等等的一些其他符号 这种字符编码规范显然用来处理英文没有什么问题 。(实际上也可以用来处理法文、德文等一些其他的西欧字符,但是不能和英文通用),但是面对中文、阿拉伯文之…
2011-05-27 20:34 · 分享 · 评论(0) · Java · 游戏 · Windows · 软件测试 · 单元测试
堆排序
因为要观察稳定性,就自己定义数据元素 package sorted.util; /* * Element用作排序算法的元素,value为其对应的值,index为其最开始时的下标 * index主要用来观察稳定行 */ public class Element { private int value ; private int index ; public int getValue() { return value; } public void setValue(int value) { this.value = value; } public int getIndex() { return …
2011-05-25 18:25 · 算法 · 评论(0) · 算法
选择排序
选择排序是这样实现的: 设数组内存放了n个待排数字,数组下标从1开始,到n结束。 i=1 从数组的第i个元素开始到第n个元素,寻找最小的元素。 将上一步找到的最小元素和第i位元素交换。 如果i=n-1算法结束,否则回到第3步 public static void selectSort(int array[]){ for(int i=0; i<array.length; i++){ int index = i; int max = array[i] ; //退出循环时,index表示最大的数的位置 for(int j=i+1; j<array.length; j++){ if(array[j]…
2011-05-25 14:58 · 算法 · 评论(0) · 算法 · J#
使用Java实现登陆WebQQ(带源码)
使用Java中的URL 和 HttpURLConnection 就可以实现模拟网页登陆! 分析登陆的协议,可以使用HttpWatcher,蛮好用的! 目前就两种网页请求方式 Get和Post 我们可以自己先写好这两个方法,以便之后调用 这个就是Get请求方式了,参数就是URL地址 public static String get(String url) { System.out.println("get>>>" + url); URL serverUrl; HttpURLConnection conn; StringBuffer res = new StringBuffer(); try {…
2011-05-24 21:22 · TX · 评论(7) · Java · FP · 百度 · Swing · QQ
VC中Static Text和GroupBox空间设置透明
VC开发的程序,要美化!设置透明,弄点背景,能稍微好看点! Static Text和GroupBox就可以设置透明! 只需要处理WM_CTLCOLOR消息就可以了!此消息是针对控件进行设置的!很好用! IDC_STATIC_NAME为空间的ID啦~ HBRUSH CConfigureDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) { HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor); // TODO: Change any attributes of the DC here…
2011-05-16 14:03 · 评论(0) · VC++
小小的总结下
tableName代表数据库中的表 fieldName代表需要查询的数据库表中的列名 cond代表查询的条件表达式, cond.getCondition()得到具体的表达式 查询函数 [code="java"]public static List> query(Connection con, String tableName, String[] fieldName, Condition cond){ List> result = new ArrayList>(); PreparedStatement psmt = null; ResultSet rs = null; try{ StringB…
2011-05-15 14:50 · SQL Server · 评论(0) · J# · SQL