Home > Net >  Big help c # how to extract the odd number in the array
Big help c # how to extract the odd number in the array

Time:11-21

Is this topic: from the keyboard input of five student number in the one dimensional array, each student number of digits to form a new short student id, according to the output from small to large order.
using System;

using System.Collections.Generic;

Using System. Linq;

Using System. The Text;


The namespace ConsoleApplication1_mopaopaixu

{

Class Program

{

The static void Main (string [] args)

{

Console. WriteLine (" this is a 'input number 5 in the array, and then realize bubble sort' program... ");

Double c=new double [] [5];

For (int number=0; Number & lt; 5; + + number)

{

The Console. Write (" please input the first number: {0} ", number + 1);
C [number]=double. Parse (the Console. The ReadLine ());

}


Int I, j;

Double m;

for (i=0; i <5; + + I)

For (j=0; J & lt; 5 - I - 1; + + j)

{

If (c [j] & gt; C [m + 1])

{

M=c [j];

C=c [j] [j + 1);

C [j + 1)=m;

}

}

Console. Write (" five digits after the bubble sort order (by size) is ");

The foreach (double var in c)

{

The Console. Write (var);//in turn read the elements in the string

The Console. Write (" ");

}

Console.ReadKey();

}

}

}

CodePudding user response:

Student number should use the string should not be used double
Remove the odd code
String id="1234567890";
Id=string. Join (", "id. Select ((x, I)=& gt; New {x} I). The Where (x=& gt; X.i % 2==0). Select (x=& gt; X.X.T oString ()));

CodePudding user response:

Student id is dried shrimp? Consists of a few digits? Illustrate some data out to see,

CodePudding user response:

refer to the second floor the wise know already should good karma response:
student id is dried shrimp? Consists of a few digits? Both get some data out look,

Student number such as 12345 five input into an array and then extract the odd bits of the five data in an array of new five short student number 12345-135, the last order

CodePudding user response:

reference 1/f, guiyang horse Ma Shanfu plugging waterproof engineering professional maintenance of swimming pool response:
student number should use the string should not be used double
Remove the odd code
String id="1234567890";
Id=string. Join (", "id. Select ((x, I)=& gt; New {x} I). The Where (x=& gt; X.i % 2==0). Select (x=& gt; X.X.T oString ()));

Thank you know how to extract each value in the array of odd bits into a new array

CodePudding user response:

reference 4 floor qq_45969794 response:
Quote: reference 1/f, guiyang horse Ma Shanfu plugging waterproof engineering professional maintenance of swimming pool response:
student number should use the string should not be used double
Remove the odd code
String id="1234567890";
Id=string. Join (", "id. Select ((x, I)=& gt; New {x} I). The Where (x=& gt; X.i % 2==0). Select (x=& gt; X.X.T oString ()));

Thank you know how to extract each value in the array the odd bit of deposited in the new array

Can you give a specific code
  •  Tags:  
  • C#
  • Related