Array (for loop + isometric substitution)

Source: Internet
Author: User

Array!

int[] Shuzu = new Int[6] {1, 2, 3, 4, 5, 6};//The index is starting from 0.             [] Indicates the number of values contained in the array! int i = shuzu[2];//here 2 represents the index of the array Shuzu! This is the format of the reference array!

/* int[] Shuzu = new Int[6];

Shuzu[0] = 1;

SHUZU[1] = 2;

SHUZU[2] = 3;//When the index is not assigned, the extracted is 0

int I=shuzu. [3];

Console.Write (i);

Console.ReadLine (); */

/* Average score and maximum minimum score are calculated!

Console.Write ("number");

int N=int. Parse (Console.ReadLine ());

int[] i = new Int[n]; Create the array I, containing the n number of values!

int zongfen = 0;

Double b = 0;

for (int a = 0; a < n; a++)

{

Console.Write ("First" + (a+1) + "person score");

I[a] = Int.      Parse (Console.ReadLine ()); Assigned value. The value of index A in the array I

zongfen+= I[a]; How the sum is represented

}

b = zongfen/n;

Console.WriteLine ("Average score" +b+ "total Score" +zongfen);

int max = i[0];    int min = i[0]; Assign a number in the array, then use if to determine the size, and then the size of the value!

for (int c = 0; c < n; c + +)

{

if (I[c] >= max)//Compare size!

{

max = I[c];

}

if (I[c] <= min)//Compare size!

{

MIN=I[C];

}

}

Console.Write ("Max" + Max + "min" + min);

Console.ReadLine ();

/* Console.Write ("Number of Persons:");

int r = Int. Parse (Console.ReadLine ());

Int[]ren=new Int[r];

for (int a = 0; a < R; a++)

{

Console.Write ("First" + (a+1) + "personal score");

Ren[a]=int. Parse (Console.ReadLine ());

}

int d = 0;

for (int b = 0; b < R; b++)//L (Descending) Order (bubble arrangement method)

{

for (int c = b; c < r-1; C + +)

{ d = ren[b]; Intermediate values are assigned before the If judgment, as if (Ren[b] < Ren[c + 1])

if (Ren[b] > ren[c + 1])//Put useful left, useless to delete. Key in if judgment size and equivalent substitution

                     {               

REN[B] = ren[c + 1];

Ren[c + 1] = D;

}

}

}

foreach (int e in ren)//Represents the creation of a new variable e from the array ren in order to take the value.

Console.Write (e);

for (int e = 0; e < r;e++)//Ibid.

{Console.Write (ren[e]);}

Console.ReadLine (); */

Array (for loop + isometric substitution)

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.