易截截图软件、单文件、免安装、纯绿色、仅160KB

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();
 }
}


相关文档:

Java 如何取得操作系统的属性

 import java.util.Enumeration;
import java.util.HashMap;
import java.util.Properties;
public class SystemProperties
{
public static String LINE_SEPARATOR = "line.separator";
public static String FILE_SEPARATOR = "file.separator";
public static String USER_LANGUAGE = "user.language"; ......

Java 时间范围 Util

 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 ......

在Eclipse和NetBeans中导入Java API

 工欲善其事,必先利其器。熟悉开发环境可以让你更快更好更舒服地开发软件。就如同VC/.net开发人员离不开msdn,java开发人员往往也离不开java API。下面介绍下如何在Eclipse和NetBeans中导入java API。使之可以方便快速地查找,定位。
  本文适合与刚刚接触Eclipse或NetBeans的java开发人员,或者是有经验的使用Ec ......

Java数据库包java.sql.*详解(jdk1.6)

1:应用程序不再需要使用 Class.forName() 显式地加载 JDBC 驱动程序。当前使用 Class.forName() 加载 JDBC 驱动程序的现有程序将在不作修改的情况下继续工作。
2:需要注意以下命令:
executeUpdate:是最基础的数据库的更新、插入和删除操作。效率低下。   
executeQuery:是最基础的执行查询语句,同样 ......

Java中的字符集编码入门 2

 
  说到GB2312和GBK就不得不提中文网页的编码。尽管很多新开发的Web系统和新上线的注重国际化的网站都开始使用UTF-8,仍有相当一部分的中文媒体坚持使用GB2312和GBK,例如新浪的页面。其中有两点很值得注意。
  第一,页面中meta标签的部分,常常可以见到charset=GB2312这样的写法,很不幸的是,这个“cha ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号