C # Exercises

Source: Internet
Author: User

Exercise 1: Prompt the user to enter a user name, and then prompt for a password, if the user name is "admin" and the password is "888888", the prompt is correct, otherwise prompt error, if the user name is not admin also prompts the user name does not exist.

1 usingSystem;2 usingSystem.Collections.Generic;3 usingSystem.Linq;4 usingSystem.Text;5 6 /*7 Exercise 1: Prompt the user for a user name, and then prompt for a password,8 * If the user name is "admin" and the password is "888888", the prompt is correct, otherwise prompt error,9 * If the user name is not admin, the user name does not exist. Ten  */ One namespaceConsoleApplication1 A { -     class Program -     { the         Static voidMain (string[] args) -         { -             stringName//declaring an account variable -             stringPassword//declaring a password variable +  -             //Prompt user to enter user name +Console.WriteLine ("Please enter user name:"); A             //Receive user input atName =console.readline (); -             //Prompt user to enter password -Console.WriteLine ("Please enter your password:"); -             //Receive user input -Password =console.readline (); -  in             //determine if the user name and password are "admin" and "888888" (with If) -             if(Name = ="Admin"&& Password = ="888888") to             { +Console.WriteLine ("Enter right! "); -             } the             Else *             { $                 if(Name = ="Admin")Panax Notoginseng                 { -Console.WriteLine ("Password input Error! "); the                 } +                 Else A                 { theConsole.WriteLine ("user name does not exist! "); +                 } -             } $             //will pause, press any key to close the window $ Console.readkey (); -         } -     } the}
Exercise 1

Exercise 2: Prompt the user to enter the age, if greater than or equal to 18, tells the user can view, if less than 10 years old, then told not to allow viewing, if greater than or equal to 10 years old, prompts the user whether to continue viewing (yes, no), if the input is yes prompts the user to view, otherwise the prompt cannot be viewed (Give the test case.) )

Exercise 3: Remove the largest integer from an array of integers

Exercise 4: Computes the and of all elements of an array of integers.

Exercise 5: Output a string array to the form of a | split, such as {"Floating clouds", "God Horse", "shuttle"} Array output as "cloud | God Horse | shuttle". Do not use. NET built-in methods such as String.Join.

Exercise 6: There is an array of integers, declare an array of strings, convert the value of each element in an integer array to a string and save it to a string array.

Exercise 7: Invert the order of the elements of a string array. {"3", "a", "8", "haha"} converted to {"Haha", "8", "A", "3"}. Tip: The first and length-i-1 are exchanged.

C # Exercises

Related Article

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.