java 找出4位数的所有吸血鬼数字
/**
* 找出四位数所有的吸血鬼数字
* 吸血鬼数字:位数为偶数的数字可以由一对数字相乘而得,这对数字包含乘积一半的位数
* 如:1260 = 21*60
*/
public class Vampire {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
String s="";
for(int i=1; i<10; i++){
for(int j=0; j<10; j++){
s += (10*i+j)+" ";
}
}
System.out.println(s);
String[] arr = s.split(" ");
System.out.println("两位数的个数为:"+arr.length);
int a,b;
int count=0;
for(int j=0; j<arr.length; j++){
for(int k=0; k<arr.length; k++){
a = Integer.valueOf(arr[j]).intValue();
b = Integer.valueOf(arr[k]).intValue();
//为能以两个0结尾
if(a*b<10000 && a*b>1000 && (a*b)%100!=0){
count++;
System.out.print(arr[j]+"_"+arr[k]+" ");
}
}
System.out.println();
}
System.out.println("the total number is "+count); //6370
}
}
相关文档:
//静态块(static block):如下所示
public class StaticBlock1
{
static
{
System.out.println("static block");
......
Database
MySQL
PostgreSQL
Firebird(suitable for embedded database)
HSQLDB(160K)
DB Tie
Hibernate
Ibatis
JDO
OSCache
JBossCache
Business Tie
Spring
UI Tie
Structs
JSF
Tapestry
Webwork
Flex
DWR(Ajax
Framework)
ZK(Ajax
Framework)
Dojo(Ajax
Framework)
Development Tools
......
2009-11-11 18:06:09
/**
*
* @author Ice*
*/
public class RarUtil{
public static void main(String args[]) throws Exception {
String compress = "D:\\test.rar";// rar压缩文件
String decompression = "D:\\";// 解压路径
unZip(compress, decompression);
}
/** ......
public class FindPrime {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int num = 100;
String s = "100以内的素数:";
for (int i = 1; i <= num; i++) {
int count = 0;
for (int j = 1; j <= (int) Math.s ......