C # learning notes experiment 3_1 output odd exercises

Source: Internet
Author: User

// The ACM progress has been slowed down. This is the first half of the semester. I will make up the missed lessons and start C # learning.

03rd lab Question 1

1. Write a console application. Enter a group of Integers to output all odd numbers.
Tip: Use the string Split Function

Usage of the Split function:

The Split function returns a zero-dimensional array containing a specified number of substrings.

Syntax
Split (expression [, delimiter [, count [, start])
The syntax of the Split function includes the following parameters:
Parameter description
Expression is required. A string expression that contains a substring and a separator. If expression is a zero-length string, Split returns an empty array, that is, an array that does not contain elements and data.
Delimiter is optional. Character used to identify the substring boundary. If omitted, use space ("") as the separator. If delimiter is a zero-length string, a single element array containing the entire expression string is returned.
Count is optional. Number of substrings to be returned.-1 indicates that all substrings are returned.
Compare is optional. Indicates the value of the comparison type used to calculate the substring. For values, see the "Settings" section.
Set
The compare parameter can have the following values:
Constant Value description
VbBinaryCompare 0 performs binary comparison.
VbTextCompare 1 performs text comparison.

See http://www.cnblogs.com/gergro/archive/2006/04/06/368598.html for details

Code:

/*** Author: CY _ * experiment 3_1 * indicates the number of input strings, and all the odd numbers are output */using System; using System. collections. generic; using System. linq; using System. text; using System. threading. tasks; namespace test3_1 {class Program {static void Main (string [] args) {Odd. oddNumber () ;}} class Odd {public static void oddNumber () {Console. writeLine ("input integer, separated by ',':"); string x = Console. readLine (); string [] n = x. split (','); for (int I = 0; I
 
  


Run:


Zookeeper

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.