Home > Net >  C # array problem
C # array problem

Time:09-24

. Will be a positive integer sequence {K1. K. 2... K9} it either good or bad -- a new sequence, a new sequence of several smaller than K1 is in front of the K1 (left), than K1 number behind the K1 (right side), implement this functionality to code function, finally calling function will new sequence output console,

Example: the sequence {6,91,25.4. 7, 3} after rearrangement become,4,5,2,1,6,8,9,7 {3}

CodePudding user response:

The problem is not difficult to.. But your Demo is problematic.

K1=1, 2, 3, 4, 5 6 the five elements in front why is 2, 3, 4, 5 1 this sort of asc or desc or according to the sequence order.

You this seems a little bit special..


 
Var ar=new int [8] {6, 9, 1, 2, 5, 4, 7, 3};
Var k1=ar. FirstOrDefault ();
Var rs=string. Join (", ", ar, Where (d=& gt; D & lt; K1)) + ", "+ k1 +", "+ string. Join (",", ar. The Where (d=& gt; D & gt; K1));
Console. WriteLine (rs);


The
reference
1,2,5,4,3,6,9,7

CodePudding user response:

reference 1st floor by_ love reply:
problem. Not hard. But your Demo is problematic.

K1=1, 2, 3, 4, 5 6 the five elements in front why is 2, 3, 4, 5 1 this sort of asc or desc or according to the sequence order.

You this seems a little bit special..


 
Var ar=new int [8] {6, 9, 1, 2, 5, 4, 7, 3};
Var k1=ar. FirstOrDefault ();
Var rs=string. Join (", ", ar, Where (d=& gt; D & lt; K1)) + ", "+ k1 +", "+ string. Join (",", ar. The Where (d=& gt; D & gt; K1));
Console. WriteLine (rs);


The
reference
1,2,5,4,3,6,9,7

I have to make this problem come, ha ha ha ha

CodePudding user response:

reference 1st floor by_ love reply:
problem. Not hard. But your Demo is problematic.

K1=1, 2, 3, 4, 5 6 the five elements in front why is 2, 3, 4, 5 1 this sort of asc or desc or according to the sequence order.

You this seems a little bit special..


 
Var ar=new int [8] {6, 9, 1, 2, 5, 4, 7, 3};
Var k1=ar. FirstOrDefault ();
Var rs=string. Join (", ", ar, Where (d=& gt; D & lt; K1)) + ", "+ k1 +", "+ string. Join (",", ar. The Where (d=& gt; D & gt; K1));
Console. WriteLine (rs);


The
reference
1,2,5,4,3,6,9,7

This code is not you, can be long
  •  Tags:  
  • C #
  • Related