Written in the C # language: Array Analyzer

Source: Internet
Author: User
Tags readline

static void Main (string[] args)
{
#region Creating an array
Console.Write ("Please enter the length of the array");
int[] numbers = new Int[int. Parse (Console.ReadLine ())];
for (int i = 0; i < numbers. Length; i++)
{
Console.Write ("Please enter the array" + (i + 1) + "item:");
Numbers[i] = Int. Parse (Console.ReadLine ());
}
Console.clear ();
#endregion
#region sort the number of groups
for (int i = 0; i < numbers. Length-1; i++)
{
for (int j = i+1; J < numbers. Length; J + +)
{
if (Numbers[i] > Numbers[j])
{
int temp = Numbers[i];
Numbers[i] = Numbers[j];
NUMBERS[J] = temp;
}

}
}
Console.WriteLine ("The number you entered is sorted as follows:");
for (int i = 0; i < numbers. Length; i++)
{
Console.Write (numbers[i]+ "\ t");
}
Console.WriteLine ();
#endregion
#region Find the odd number
Console.WriteLine ("Where the following numbers are odd:");
Find a problem
Find samples: All the numbers in an array
Find target: Sample data divided by 2 not 0
Action found: output target data
for (int i = 0; i < numbers. Length; i++)
{
int n = numbers[i];
if (n% 2! = 0)
{
Console.Write (n + "\ T");
}
}
Console.WriteLine ();

#endregion
#region Find Prime numbers
Console.WriteLine ("The following number of prime numbers:");
for (int i = 0; i < numbers. Length; i++)
{
int n = numbers[i];
BOOL Isfind = false;
for (int j = 2; J < N; j + +)
{
if (n% j = = 0)
{
Isfind = true;
Break
}
}
if (!isfind)
{
{
Console.Write (n+ "\ t");
}
}
}
#endregion
}

Written in the C # language: Array Analyzer

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.