Home > Software engineering >  Each master, I met problem ask everybody to help at work
Each master, I met problem ask everybody to help at work

Time:10-25

I met a difficult problem in the work, previously learned when reading tests using VB programming is simply college, now basically all returned to the teacher, so please do me a favor here! I met the problem is, for example, a set of data: 23 34 46 123 145 174 173.9 220.3 237.2 20.3 198.3 183.2 177.3 now contains such numerical from 20 to 300 decimal values, how to put a few of these numerical value addition, the result is within the scope of 798.8 to 800.9, that a few additive numerical display, numerical out can't repeated use, (it is best to put all the numerical value is entered the results into a set of a set of display),
Here I thank you first! QQ 315829567 mailbox [email protected] thank each prawn

CodePudding user response:

 using System; 
Using System. Collections. Generic;
Using System. Linq;
Using System. The Text;

The namespace ConsoleApplication1
{
Class Program
{
The static void Main (string [] args)
{
Var data="https://bbs.csdn.net/topics/20.3 23 34 46 123 145 174 173.9 220.3 237.2 198.3 183.2 177.3". The Split (new char [] {'}, StringSplitOptions. RemoveEmptyEntries). Select (x=& gt; Double. Parse (x));
Var result=foo (data, new double [] {}, 798.8, 800.9);
The foreach (var item result in)
{
Console. WriteLine (" sum: {0}, the items: {1} ", the item. The sum (), string. Join (", "item. The Select (x=& gt; X.T oString ())));
}
}

The static IEnumerable Foo (IEnumerable The data, IEnumerable Includenum, double min, double Max)
{
Double includenum_sum=includenum. Sum ();
If (includenum. Sum () & gt; Min & amp; & Includenum_sum & lt; Max) yield return includenum;
If (includenum. Sum () & lt; Min)
{
Foreach (double d in the data. The Except (includenum). The Where (x=& gt; Includenum_sum + x & lt; Max & amp; & (includenum. The Count ()==0 | | x & gt; Includenum. Max ())))
{
The foreach (var item in foo (data, includenum Concat (new double [] {d}), min, Max))
{
Yield return item;
}
}
}
}
}
}


Sum: 799.4, the items: 20.3, 23, 34, 46, 145, 173.9, 174, 183.2
Sum: 799.8, the items: 20.3, 23, 34, 145, 174, 183.2, 220.3
Sum: 799.7, the items: 20.3, 23, 34, 145, 173.9, 183.2, 220.3
Sum: 800.8, the items: 20.3, 23, 34, 173.9, 174, 177.3, 198.3
Sum: 800.8, the items: 20.3, 23, 46, 123, 174, 177.3, 237.2
Sum: 800.7, the items: 20.3, 23, 46, 123, 173.9, 177.3, 237.2
Sum: 800.8, the items: 20.3, 34, 46, 123, 174, 183.2, 220.3
Sum: 800.7, the items: 20.3, 34, 46, 123, 173.9, 183.2, 220.3
Sum: 800.8, the items: 20.3, 34, 46, 145, 174, 183.2, 198.3
Sum: 800.7, the items: 20.3, 34, 46, 145, 173.9, 183.2, 198.3
Sum: 799.8, the items: 20.3, 34, 173.9, 174, 177.3, 220.3
Sum: 799.8, the items: 20.3, 46, 145, 174, 177.3, 237.2
Sum: 799.7, the items: 20.3, 46, 145, 173.9, 177.3, 237.2
Sum: 799.1, the items: 20.3, 46, 174, 177.3, 183.2, 198.3
Sum: 799, the items: 20.3, 46, 173.9, 177.3, 183.2, 198.3
Sum: 799.1, the items: 20.3, 123, 198.3, 220.3, 237.2
Sum: 800.1, the items: 20.3, 145, 177.3, 220.3, 237.2
Sum: 799.4, the items: 20.3, 177.3, 183.2, 198.3, 220.3
Sum: 799.7, the items: 23, 34, 145, 177.3, 183.2, 237.2
Sum: 799.1, the items: 23, 46, 145, 173.9, 174, 237.2
Sum: 799.5, the items: 23, 145, 174, 220.3, 237.2
Sum: 799.4, the items: 23, 145, 173.9, 220.3, 237.2
Sum: 798.9, the items: 34, 46, 123, 177.3, 198.3, 220.3
Sum: 800.7, the items: 34, 46, 123, 177.3, 183.2, 237.2
Sum: 800.5, the items: 34, 173.9, 174, 198.3, 220.3
Sum: 800.5, the items: 46, 123, 174, 220.3, 237.2
Sum: 800.4, the items: 46, 123, 173.9, 220.3, 237.2
Sum: 800.5, the items: 46, 145, 174, 198.3, 237.2
Sum: 800.4, the items: 46, 145, 173.9, 198.3, 237.2
Sum: 800.8, the items: 46, 174, 177.3, 183.2, 220.3
Sum: 800.7, the items: 46, 173.9, 177.3, 183.2, 220.3
Sum: 799.1, the items: 123, 145, 173.9, 174, 183.2
Sum: 800.8, the items: 145, 198.3, 220.3, 237.2
Press any key to continue...

CodePudding user response:

Moderators can you teach me the private chat I quickly sorrow died, now used to reading when learning VB simple operation, all returned to the teacher now, QQ: 315829567 my contact information

CodePudding user response:

refer to the second floor u012430713 response:
webmaster can you teach me the private chat I quickly sorrow died, now used to reading when learning VB simple operation, all returned to the teacher now, QQ: 315829567 I contact

Download a c #, create a new console application, paste the above code, you can get the results

Download address: http://go.microsoft.com/? Linkid=9709940

CodePudding user response:

Using C language? Then there is the inside of the Numbers can't reuse

CodePudding user response:

reference 4 floor u012430713 response:
in C? Then there is the inside of the Numbers can't reuse to do

Do you see the results of which is wrong,

CodePudding user response:

I see the moderator is that different together the same result: thank you very much! I am copying code directly in the past, can

CodePudding user response:

refer to 6th floor u012430713 response:
I see the moderator is that different together the same result: thank you very much! Have I been directly copy the code in the past, you can

Right,

Is a C #, not C, make no mistake about it, need at least 2010 version, also can be 2012, 2013,

CodePudding user response:

I use you gave me to download directly thank you thank you moderator very

CodePudding user response:

Moderators how I run well, you can remote help me? My QQ315829567
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related