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