zoukankan      html  css  js  c++  java
  • 【专题】取得一个数各个位的值

    class Program
        {
            static void Main(string[] args)
            {
                /*
                int i = 365;
                //就是三位数
    
                int sheng = 365;
                int ge = sheng % 10;
    
               // int ge = i % 10;
                Console.WriteLine("个位"+ge);
                //int sheng = i / 10;//36
                sheng = sheng / 10;
                Console.WriteLine("剩" + sheng);
    
                int shi = sheng % 10;
                Console.WriteLine("十位" + shi);
    
                sheng = sheng / 10;
                Console.WriteLine("剩" + sheng);
    
                int bai = sheng % 10;
                Console.WriteLine("百位"+bai);
                sheng = sheng / 10;
                Console.WriteLine("剩" + sheng);
                */
    
                /*
                int n = 3721886;
                int sheng = n;
                while (sheng != 0)
                {
                    int wei = sheng % 10;
                    Console.WriteLine(wei);
    
                    sheng = sheng / 10;
                }*/
    
                int n = 3721886;
                string s = n.ToString();//项目中哪个方便用哪个。面试的时候尽量不用.net内置的方法
                for (int i = 0; i < s.Length; i++)
                {
                    char ch = s[i];
                    int iWei = ch-'0';//'1'→1
                    //Console.WriteLine(ch);
                    Console.WriteLine(iWei);
                }
                Console.ReadKey();
            }
        }
  • 相关阅读:
    2016四川省赛 Floyd-Warshall
    CF374 Maxim and Array
    CF374 Journey
    hdu5730 Shell Necklace
    hihocoder1388 Periodic Signal
    hihocoder1391 Country
    hdu 5903 Square Distance
    hdu5904 LCIS
    Python学习-2.安装IDE
    Python学习-1.安装Python
  • 原文地址:https://www.cnblogs.com/lolitagis02/p/8094685.html
Copyright © 2011-2022 走看看