C # Programming: Given a positive integer to find a number of digits and reverse the output

Source: Internet
Author: User
<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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.