CodePudding user response:
Num % 10 can obtain digital lowestAnd then kept num/=10 modulus can get all of the position
CodePudding user response:
The static void the Get (int a){
Int len=a.T oString (). The Length;
For (int I=len - 1; I & gt;=0; I -)
{
Int b=a/(int) Math. Pow (10, I) % 10;
Console. WriteLine (b.T oString ());
}
}
CodePudding user response:
Said nothing to tell mathematical Angle, the best you can as f (x) (g), but c # func temporarily does not support the yield return, so I give examples for the way the recursive implementation
int numsource=541;
Var res=getnum (numsource). ToList ();
IEnumerableGetnum (int num)
{
If (num/10 & gt; 0)
{
Var temp=getnum (num/10);
Foreach (var I in temp)
{
Yield return I;
}
}
Yield return num % 10;
}
CodePudding user response:
In 345, for example345/1%10 - & gt; 5
345/10%10 - & gt; 4
345/100%10 - & gt; 3
CodePudding user response:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Using System. The Threading. The Tasks;
The namespace ConsoleApplication1
{
Class Program
{
The static void Main (string [] args)
{
ListList=GetList (123456);
The foreach (int the number in the list)
{
Console. WriteLine (number);
}
}
The static ListGetList (int number)
{
ListList=new List (a);
While (number!=0)
{
List. The Add (number % 10);
Number=number/10;
}
List. The Reverse ();
Return the list;
}
}
}
CodePudding user response:
Directly to an integer to a string and then output each charCodePudding user response: