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();
}
}
相关文档:
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列
......
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 ......
import java.util.Date;
public class TimeSpan
{
public final static TimeSpan ZERO = new TimeSpan(0);
private long _totalMilliSeconds = 0;
public TimeSpan(long totalMilliSeconds)
{
_totalMilliSeconds = totalMilliSeconds;
}
public TimeSpan(Date afterDate, Date beforeDat ......
说到GB2312和GBK就不得不提中文网页的编码。尽管很多新开发的Web系统和新上线的注重国际化的网站都开始使用UTF-8,仍有相当一部分的中文媒体坚持使用GB2312和GBK,例如新浪的页面。其中有两点很值得注意。
第一,页面中meta标签的部分,常常可以见到charset=GB2312这样的写法,很不幸的是,这个“cha ......
学习Java程序主要包含以下四个部分。
(1)编辑代码 edit code
(2)保存代码 save code
(3)编译代码 compiler code
(4)运行程序 run program
第一个程序文件HelloWorld.java
public class HelloWorld {
public static void main(String[] args){
......