博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【小朽开源路-①初出茅庐】十进制转(2到16)进制原理及安卓实现
阅读量:4588 次
发布时间:2019-06-09

本文共 2736 字,大约阅读时间需要 9 分钟。

前言

  我的开源路声明:

  为了实现自己的目标,不幸自己就选择在博客园上练习自己英语。希望英语多,中文少,然后渐渐地成为习惯。加油!

Subject

  实现十进制转(2到16)进制原理及安卓

 

The Principle (原理)

  ①the Stack ADT (栈知识)

    小朽是活学活用,栈知识复习

  ②the Short division (短除法)

    

  Start...

              the jar struckture

   

  ALStack.java

package sedion.jeffli.action;import java.util.ArrayList;import java.util.Stack;/** * My Open-Source road * @author Jeff Li * * @param 
*/public class ALStack
extends Stack
{ /** * */ private static final long serialVersionUID = -1261738006146239371L; private ArrayList
stackList = null; //create an empty stack by creating an empty ArrayList public ALStack(){ stackList = new ArrayList
(); } }

  

  BaseStr.java

      

package sedion.jeffli.action;import java.util.Scanner;public class BaseStr {    public static void main(String[] args) {        int num , b;        Scanner keyIn = new Scanner(System.in);                System.out.print("Enter a decimal number: ");        num = keyIn.nextInt();                System.out.print("Enter a base (2 to 16): ");        b = keyIn.nextInt();        System.out.print(" "+num+" base "+b+" is "+baseString(num, b));    }        //the short division principle    public static String baseString(int num,int b){        //digitChar.charAt(digit) is the character that represents the digit , 0 <= digit <= 15        String digitChar = "0123456789ABCDEF",numStr = "";                //stack holds the base-b digits of num        ALStack
stk = new ALStack
(); do{ //push right-most digit on the stack stk.push(digitChar.charAt(num % b)); //remove right-most digit form num num /= b; }while(num != 0); while(!stk.isEmpty()){ //pop stack and add digit on top of stack to numStr numStr += stk.pop().charValue(); } return numStr; }}

 

    *核心

      短除法原理,短除就是在除法中写除数的地方写两个数共有的质因数,然后落下两个数被公有质因数整除的商,之后再除,以此类推,直到结果互质为止

 

                

 

    实现demo,its a bit easy ,right?       
       //push right-most digit on the stack            stk.push(digitChar.charAt(num % b));                        //remove right-most digit form num            num /= b;

 

Andriod Practice 

   源码下载:链接:http://pan.baidu.com/share/link?shareid=1403222381&uk=3307409781 密码:ub64

   应用下载:链接:http://pan.baidu.com/share/link?shareid=1403222381&uk=3307409781 密码:ub64

 

   勿喷,效果图

    

 

寄读者,寄知识来源

   读者,你好!你我不相识,谢谢你们支持。我的梦想会越来越接近。keep on,共勉!

   知识来源 

    知识来源于想着,我走路想着玩一个。就玩好了,星期六快乐。

转载于:https://www.cnblogs.com/Alandre/p/3602526.html

你可能感兴趣的文章
find out the neighbouring max D_value by counting sort in stack
查看>>
ASP.NET MVC之分部视图和ChildAction(三)
查看>>
逆向工程 找不到文件
查看>>
OpenJ_Bailian——4115鸣人和佐助(带状态的A*)
查看>>
8.现代计算机的组成
查看>>
oracle系列--第三篇 Oracle的安装
查看>>
Javascript模块化编程(二):AMD规范
查看>>
吴裕雄--天生自然 物理学习与探索笔记:位移和时间
查看>>
[译]JavaScript:打破所有规则
查看>>
0909对操作系统的认识
查看>>
windows下的批处理bat文件和Linux下的shell文件的互相转换
查看>>
BZOJ【1606】购买干草
查看>>
MySQL 删除重复数据实例
查看>>
。。。
查看>>
【HDU 4276】The Ghost Blows Light(树形DP,依赖背包)
查看>>
一分钟将你的WPF应用程序变身成炫彩动态Metro风格
查看>>
iOS 学习资料Blog 技术论坛等,不断添加中。。。。
查看>>
简单实现Tabbar的隐藏显示动画 By H罗
查看>>
电脑自动开机设置教程
查看>>
rpc接口mock平台
查看>>