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,