java 大数类
import java.io.*;
class BigInt
{
int a[];
int len;
BigInt(String str)
{
{
len=str.length();
a=new int[len];
for(int i=0;i<len;i++)
{
this.a[i]=str.charAt(i)-48;
}
}
}
public BigInt bigplus(BigInt b)
{
BigInt sum;
int l;
int m=len-1;
int n=b.len-1;
int max;
if(len>=b.len)
{
l=b.len;
max=len-1;
sum=this;
}
else
{
l=len;
sum=b;
max=b.len-1;
}
for(int i=0;i<l;i++)
{
sum.a[max]=a[m]+b.a[n];
if(max!=0&&sum.a[max]>=10)
{
sum.a[max]=sum.a[max]-10;
sum.a[max-1]++;
}
m--;
n--;
max--;
}
return sum;
}
public void output()
{
for(int i=0;i<len;i++)
{
System.out.print(a[i]);
}
}
}
class TestBig
{
public static void main(String[] args) throws IOException
{
String str1;
String str2;
System.out.println("请输入大数1:");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
str1=br.readLine();
System.out.println("请输入大数2:");
BufferedReader br1=new BufferedReader(new InputStreamReader(System.in));
str2=br1.readLine();
BigInt a1=new BigInt(str1);
BigInt a2=new BigInt(str2);
BigInt a3=a1.bigplus(a2);
a3.output();
}
}
相关文档:
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import com.paic.is.dispatch.TMPEntry;
public class DateTimeUtil
{
public final static String LOCAL_SHORT_DATE_FORMAT = "yyyy-MM-dd";
public final static String LOCAL_LONG_DATE_FORMAT = "yyyy-MM-dd H ......
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.io.SAXReader;
public class DocumentUtil
{
public static Document loadXMLByAbsolutePath(String absoluteFilePath, String logFileName)
{
SAXReader saxReader = new SAXReader();
Document document = null;
try ......
我在玩一个网页游戏的时候总是按一个键。觉着累。所以就写了一个程序。
Robot r = new Robot();
// 按键
r.keyPress(51);
// 释放
r.keyRelease(51);
用Robot 这个实现自动化的类就可做到。实现这个游戏一直按下这个键子。
也可以做按键精灵类似的软件。但是这个类只能应用当前窗口。怎么能把这个程序固定在某 ......
/**
* 把指定的内容写到指定路径的文本文件上
*
* @param path指定路径
* @param context 要写的内容
*/
public static void writeFile(String path, String context) {
// 从控制台输入内容写入文件
try {
FileWriter fw = new FileWriter(path, true);
PrintWriter pw = new Print ......
说到GB2312和GBK就不得不提中文网页的编码。尽管很多新开发的Web系统和新上线的注重国际化的网站都开始使用UTF-8,仍有相当一部分的中文媒体坚持使用GB2312和GBK,例如新浪的页面。其中有两点很值得注意。
第一,页面中meta标签的部分,常常可以见到charset=GB2312这样的写法,很不幸的是,这个“cha ......