zoukankan      html  css  js  c++  java
  • 整数转字符串

    代码
            static string TransToString(int value)
            {
                
    int step = 1000000000;
                
    char[] results = new char[10];
                
    int index = 0;
                
    if (value < 0)
                {
                    results[index
    ++= '-';
                    value 
    = 0 - value;
                }
                
    while (value / step == 0)
                    step 
    /= 10;
                
    while (step!=0&&value / step >= 0)
                {
                    
    if (value / step > 0)
                    {
                        results[index
    ++= (char)('0' + value / step);
                        value 
    = value % step;
                        step 
    /= 10;
                    }
                    
    else if (value / step == 0)
                    {
                        results[index
    ++= '0';
                        step 
    /= 10;
                    }
                }           
                
    return new string(results, 0, index);
            }
  • 相关阅读:
    C#中异步和多线程的区别
    猫 老鼠 人的编程题
    C#中数组、ArrayList和List三者的区别
    经典.net面试题目
    sql有几种删除表数据的方式
    内存池的实现
    A*算法为什么是最优的
    传教士与野人问题
    d3d导致cairo不正常
    c++中的signal机制
  • 原文地址:https://www.cnblogs.com/qixue/p/1665872.html
Copyright © 2011-2022 走看看