今天是第二十五天早上和以前一样是在写算法的题目
然后在有一个幸运数的打表题 用到了vector的删除操作 然后看了一点
这里就不多说了
然后java看了大数相关的知识
之前写算法的时候经常被大数困扰
下一步准备找题目试试手
上总结
//**1.大数值**
//在写题的过程中,我们会遇到这样的情况,题目很好操作,但是数据很大。
//这样在算法中有专门的类型,叫大数
//java.math中有两个类 BigInteger BigDecimal 他们可以处理包含任意长度的数字序列的数值
//1.BigInteger实现任意精度的整数运算
//2.BigDecimal实现任意精度的浮点数运算
//使用静态的valueOf方法可以将普通的数值转换为大数值 但是转换为大数值之后不能用+ * 这样的运算符
//但是有add multiply方法
BigInteger c = a.add(b);//c = a + b;
BigInteger d = c.multiply(b.add(BigInteger.valueOf(2))); //d = c*(b+2);
**API java.math.BigInteger**
1.BigInteger add(BigInteger other)
2.BigInteger subtract(BigInteger other)
3.BigInteger multiply(BigInteger other)
4.BigInteger divide(BigInteger other)
5.BigInteger mod(BigInteger other)\
6.int BigInteger compareTo(BigInteger other)
//如果这个大数和参数(大数)相同,返回0;
//如果这个大数小于other 返回负数
//如果这个大数大于other 返回正数
7.static BigInteger valueOf(long x)
//返回值等于X的大整数
API java.math.BigDecimal
1.BigDecimal divide(BigDecimal other RoundingMode mode)5.0
//求浮点型数的商 要舍入
2.static BigDecimal valueOf(long x,int scale)
//返回值为x 或者 x/10^scale的一个大实数
//2.for each loop
//java中有一个功能很强的循环结构。
//格式:for(variable:collection) statement
for(int element:a)
System.out.println(element);
现在去吃饭
吃完饭回来继续看java
//1.Applet程序 Application let
//1.Applet类
java.lang.Object
java.awt.Component
java.awt.Container
java.awt.Panel
java.applet.Applet
Applet类是Panel的子类 也是一个容器。
特点:1> Applet程序必须有一个Applet类或者它的子类
2> Applet程序没有main方法
3> Applet方法名应该和其中的public类名相同
4> Applet是一个小程序不能独立运行要嵌入到另一个应用程序中去
//2.运行Applet程序
//1)HTML文件
//html文件是一个以html或者htm为扩展名的文件,这类文件可以在IE浏览器中运行。
//smp71.html
//<applet code = smp71.class height = 100 width = 500> //code = smp71.class 表示调smp71.class文件
//相当于smp71.class的执行命令
//height width表示打开窗口的高度和宽度
// </applet> //代表程序的结束
//2)运行html文件
//1> 在IE浏览器或者其他浏览器打开
//打开一个浏览器,在网址栏输入smp71.html文件的地址和文件名 按回车
//2> 在命令提示窗口运行
//通过appletviewer命令可以在命令提示窗口运行applet程序
老规矩:
你只有失败过,才知道成功来的不容易。