<span style= "color: #FF0000;" > First step: Convert the input number to string N. ToString () Second step: Find the length of the string is the number of digits of a positive integer step three: output from backward forward </span> code: using System;using system.collections.generic;using System.linq;using system.text;//to a positive integer,//requirements: First, it is a number of digits, two, reverse print out the numbers. Namespace consoleapplication3{ class program { static void Main (string[] args) { int n = 12345;// First define a positive integer string s = n.tostring ();//Convert a number to a string int weishu = s.length;//The length of the string is a positive integer number of bits Console.WriteLine ( "The number of digits is {0}\n", Weishu); Console.Write ("Reverse output:"); for (int i = weishu-1; I >= 0; i--) { console.write (s[i]);//from backward to one character output } console.read ();
} }}
C # Programming: Given a positive integer to find a number of digits and reverse the output