Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想从数字的开头开始依次获取一个长数字的数字。我想通过使用 while、for 或 if 来做到这一点。任何想法?
int i = 123456; foreach (char c in i.ToString()) { Console.Write(c); }
假设你有一个数字 n
int n = 12345;
得到数字
int n = 12345; for (int i = 1; i <= n; i*=10) { int d = (n % (i*10))/i; Console.WriteLine(d); }