Beginner's case in C # language

Source: Internet
Author: User

Source code: Reverse Order output

Console.Write ("Please enter a string:");            string input = console.readline ();            for (int i = input. Length-1; I >=0; i--)            {                console.write (input[i]);            }  

Effect: 1235 Output effect 5321

Source code: Fibonacci Sequence (1, 1, 2, 3, 5 、、、、)

            #region//Get the length of the user input, save to the variable n             console.write ("Please enter a number:");            int n = int. Parse (Console.ReadLine ());            int[] numbers = new int[n];//Save the variable n to the array numbers                       #endregion            #region//Create an array of length n, and sequentially save each digit for            (int i = 0; i < numbers. Length; i++)//i represents the             {                if (I <= 1) {Numbers[i] = 1 of the index in the array;} Index i is less than or equal to 1 o'clock, the index in the array has a value of 1                else {numbers[i] = Numbers[i-1] + numbers[i-2];} Otherwise the index position -1,-2 gets the number of the next index position             }           //foreach (int i in Numbers[n]) {Console.WriteLine (i);}                        #endregion            #region//traverse the output array contents for            (int i = 0; i < numbers. Length; i++) {Console.Write (numbers[i] + "\ T");} Console.ReadLine (); #endregion      

Effect:

Beginner's case in C # language

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.