Search Results

Search found 3021 results on 121 pages for 'min hong tan'.

Page 4/121 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • how to use sort function the same way as max or min in mathematica

    - by Qiang Li
    Please take a look at the following code: Sort[{1, y, x}, Greater] Max[{1, x, y}] x = 1 y = 2 Sort[{1, y, x}, Greater] Max[{1, x, y}] It is interesting to note that the first Sort always produce a definite result while the first Max does not, even when Greater is specified. Note I have not given any numerical values for x and y. Why is this and how can I have a Sort function behave the same way as the Max (or Min) function? Thanks!

    Read the article

  • Parallelism in .NET – Part 6, Declarative Data Parallelism

    - by Reed
    When working with a problem that can be decomposed by data, we have a collection, and some operation being performed upon the collection.  I’ve demonstrated how this can be parallelized using the Task Parallel Library and imperative programming using imperative data parallelism via the Parallel class.  While this provides a huge step forward in terms of power and capabilities, in many cases, special care must still be given for relative common scenarios. C# 3.0 and Visual Basic 9.0 introduced a new, declarative programming model to .NET via the LINQ Project.  When working with collections, we can now write software that describes what we want to occur without having to explicitly state how the program should accomplish the task.  By taking advantage of LINQ, many operations become much shorter, more elegant, and easier to understand and maintain.  Version 4.0 of the .NET framework extends this concept into the parallel computation space by introducing Parallel LINQ. Before we delve into PLINQ, let’s begin with a short discussion of LINQ.  LINQ, the extensions to the .NET Framework which implement language integrated query, set, and transform operations, is implemented in many flavors.  For our purposes, we are interested in LINQ to Objects.  When dealing with parallelizing a routine, we typically are dealing with in-memory data storage.  More data-access oriented LINQ variants, such as LINQ to SQL and LINQ to Entities in the Entity Framework fall outside of our concern, since the parallelism there is the concern of the data base engine processing the query itself. LINQ (LINQ to Objects in particular) works by implementing a series of extension methods, most of which work on IEnumerable<T>.  The language enhancements use these extension methods to create a very concise, readable alternative to using traditional foreach statement.  For example, let’s revisit our minimum aggregation routine we wrote in Part 4: double min = double.MaxValue; foreach(var item in collection) { double value = item.PerformComputation(); min = System.Math.Min(min, value); } .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } Here, we’re doing a very simple computation, but writing this in an imperative style.  This can be loosely translated to English as: Create a very large number, and save it in min Loop through each item in the collection. For every item: Perform some computation, and save the result If the computation is less than min, set min to the computation Although this is fairly easy to follow, it’s quite a few lines of code, and it requires us to read through the code, step by step, line by line, in order to understand the intention of the developer. We can rework this same statement, using LINQ: double min = collection.Min(item => item.PerformComputation()); Here, we’re after the same information.  However, this is written using a declarative programming style.  When we see this code, we’d naturally translate this to English as: Save the Min value of collection, determined via calling item.PerformComputation() That’s it – instead of multiple logical steps, we have one single, declarative request.  This makes the developer’s intentions very clear, and very easy to follow.  The system is free to implement this using whatever method required. Parallel LINQ (PLINQ) extends LINQ to Objects to support parallel operations.  This is a perfect fit in many cases when you have a problem that can be decomposed by data.  To show this, let’s again refer to our minimum aggregation routine from Part 4, but this time, let’s review our final, parallelized version: // Safe, and fast! double min = double.MaxValue; // Make a "lock" object object syncObject = new object(); Parallel.ForEach( collection, // First, we provide a local state initialization delegate. () => double.MaxValue, // Next, we supply the body, which takes the original item, loop state, // and local state, and returns a new local state (item, loopState, localState) => { double value = item.PerformComputation(); return System.Math.Min(localState, value); }, // Finally, we provide an Action<TLocal>, to "merge" results together localState => { // This requires locking, but it's only once per used thread lock(syncObj) min = System.Math.Min(min, localState); } ); Here, we’re doing the same computation as above, but fully parallelized.  Describing this in English becomes quite a feat: Create a very large number, and save it in min Create a temporary object we can use for locking Call Parallel.ForEach, specifying three delegates For the first delegate: Initialize a local variable to hold the local state to a very large number For the second delegate: For each item in the collection, perform some computation, save the result If the result is less than our local state, save the result in local state For the final delegate: Take a lock on our temporary object to protect our min variable Save the min of our min and local state variables Although this solves our problem, and does it in a very efficient way, we’ve created a set of code that is quite a bit more difficult to understand and maintain. PLINQ provides us with a very nice alternative.  In order to use PLINQ, we need to learn one new extension method that works on IEnumerable<T> – ParallelEnumerable.AsParallel(). That’s all we need to learn in order to use PLINQ: one single method.  We can write our minimum aggregation in PLINQ very simply: double min = collection.AsParallel().Min(item => item.PerformComputation()); By simply adding “.AsParallel()” to our LINQ to Objects query, we converted this to using PLINQ and running this computation in parallel!  This can be loosely translated into English easily, as well: Process the collection in parallel Get the Minimum value, determined by calling PerformComputation on each item Here, our intention is very clear and easy to understand.  We just want to perform the same operation we did in serial, but run it “as parallel”.  PLINQ completely extends LINQ to Objects: the entire functionality of LINQ to Objects is available.  By simply adding a call to AsParallel(), we can specify that a collection should be processed in parallel.  This is simple, safe, and incredibly useful.

    Read the article

  • Hide ticks at Min and Max in WPF Slider

    - by gehho
    Hi, I want to display a Slider ranging from 0.5 to 1.5 with only one tick mark at 1.0 to mark the center and default value. I have defined a Slider as follows: <Slider Minimum="0.5" Maximum="1.5" IsMoveToPointEnabled="True" IsSnapToTickEnabled="False" Orientation="Horizontal" Ticks="1.0" TickPlacement="BottomRight" Value="{Binding SomeProperty, Mode=TwoWay}"/> However, besides a tick mark at 0.0 this Slider also shows tick marks at 0.5 and 1.5, i.e. the Minimum and Maximum values. Is there a way to hide these min/max tick marks?! I checked all properties and tried changing some of them, but did not have success so far. Thanks, gehho.

    Read the article

  • min() and max() give error: TypeError: 'float' object is not iterable

    - by PythonUser3.3
    markList=[] Lmark=0 Hmark=0 while True: mark=float(input("Enter your marks here(Click -1 to exit)")) if mark == -1: break markList.append(mark) markList.sort() mid = len(markList)//2 if len(markList)%2==0: median=(markList[mid]+ markList[mid-1])/2 print("Median:", median) else: print("Median:" , markList[mid]) Lmark==(min(mark)) print("The lowest mark is", Lmark) Hmark==(max(mark)) print("The highest mark is", Hmark) My program is a basic grade calculator using lists. My program asks the user to input their grades into a list in which it then calculates your average and finds your lowest and highest mark. I have found the average but I can't seem to figure out how to find the lowest and highest grade. Can you please show me pr tell me what to do?

    Read the article

  • min max coordinate of cells , given cell length in c#

    - by Raj
    Please see attached picture to better understand my question i have a matrix of cells of [JXI] , cell is square in shape with length "a" my question is .. is there a way to use FOR loop to assign MIN,MAX coordinate to each cell taking origin (0,0) at one corner Thanks "freeimagehosting.net/uploads/3b09575180.jpg" i was trying following code but no success int a ; a = 1; for (int J=1; J<=5; J++) { for (int I = 1; I <= 5; I++) { double Xmin = ((I - 1)*a ); double Ymin = ((J - 1) * a); double Xmax = (I * a ); double Ymax = (J * a); } }

    Read the article

  • Signature of Collections.min/max method

    - by Marco
    In Java, the Collections class contains the following method: public static <T extends Object & Comparable<? super T>> T min(Collection<? extends T> c) Its signature is well-known for its advanced use of generics, so much that it is mentioned in the Java in a Nutshell book and in the official Sun Generics Tutorial. However, I could not find a convincing answer to the following question: Why is the formal parameter of type Collection<? extends T>, rather than Collection<T>? What's the added benefit?

    Read the article

  • jquery datatable.min.js sorting issue?

    - by Karthik
    In my project, i am using the jquery pagination of jquery.dataTables.min.js. In that when i use ascending or descending in query, it will not displayed properly. The problem is result can be shown in form of : Sl. No. 1 10 11 12 13 | | | 19 2 3 4 5 like this, But i need the result Sl. No. 1 2 3 4 5 | | 9 10 11 12 13 This is because of jquery only. I want to know how can i clear this? But in someplace it is displayed properly and in someplace is not displayed properly.

    Read the article

  • Min-Ordered Bionomial Heap Insertion java

    - by Charodd Richardson
    Im writing a java code to make a min-ordered Binomial Heap and I have to Insert and Remove-min. I'm having a very big problem inserting into the Heap. I have been stuck on this for a couple of days now and it is due tomorrow. Whenever I go to insert, It only prints out the item I insert instead of the whole tree (which is in preorder). Such as if I insert 1 it prints (1) and then I go to insert 2 it prints out (2) instead of (1(2)) It keeps printing out only the number I insert last instead of the whole preordered tree. I would be very grateful if someone could help me with this problem. Thank you so much in advance, Here is my code. public class BHeap { int key; int degree;//The degree(Number of children) BHeap parent, leftmostChild, rightmostChild, rightSibling,root,previous,next; public BHeap(){ key =0; degree=0; parent =null; leftmostChild=null; rightmostChild=null; rightSibling=null; root=null; previous=null; next=null; } public BHeap merge(BHeap x, BHeap y){ BHeap newHeap = new BHeap(); y.rightSibling=x.root; BHeap currentHeap = y; BHeap nextHeap = y.rightSibling; while(currentHeap.rightSibling !=null){ if(currentHeap.degree==nextHeap.degree){ if(currentHeap.key<nextHeap.key){ if(currentHeap.degree ==0){ currentHeap.leftmostChild=nextHeap; currentHeap.rightmostChild=nextHeap; currentHeap.rightSibling=nextHeap.rightSibling; nextHeap.rightSibling=null; nextHeap.parent=currentHeap; currentHeap.degree++; } else{ newHeap = currentHeap; newHeap.rightmostChild.rightSibling=nextHeap; newHeap.rightmostChild=nextHeap; nextHeap.parent=newHeap; newHeap.degree++; nextHeap.rightSibling=null; nextHeap=newHeap.rightSibling; } } else{ if(currentHeap.degree==0){ nextHeap.rightmostChild=currentHeap; nextHeap.rightmostChild.root = nextHeap.rightmostChild;//add nextHeap.leftmostChild=currentHeap; nextHeap.leftmostChild.root = nextHeap.leftmostChild;//add currentHeap.parent=nextHeap; currentHeap.rightSibling=null; currentHeap.root=currentHeap;//add nextHeap.degree++; } else{ newHeap=nextHeap; newHeap.rightmostChild.rightSibling=currentHeap; newHeap.rightmostChild=currentHeap; currentHeap.parent= newHeap; newHeap.degree++; currentHeap=newHeap.rightSibling; currentHeap.rightSibling=null; } } } else{ currentHeap=currentHeap.rightSibling; nextHeap=nextHeap.rightSibling; } } return y; } public void Insert(int x){ /*BHeap newHeap = new BHeap(); newHeap.key=x; if(this.root==null){ this.root=newHeap; return; } else{ this.root=merge(newHeap,this.root); }*/ BHeap newHeap= new BHeap(); newHeap.key=x; if(this.root==null){ this.root=newHeap; } else{ this.root = merge(this,newHeap); }} public void RemoveMin(){ BHeap newHeap = new BHeap(); BHeap child = new BHeap(); newHeap=this; BHeap pos = newHeap.next; while(pos !=null){ if(pos.key<newHeap.key){ newHeap=pos; } pos=pos.rightSibling; } pos=this; BHeap B1 = new BHeap(); if(newHeap.previous!=null){ newHeap.previous.rightSibling=newHeap.rightSibling; B1 =pos.leftmostChild; B1.rightSibling=pos; pos.leftmostChild=pos.rightmostChild.leftmostChild; } else{ newHeap=newHeap.rightSibling; newHeap.previous.rightSibling=newHeap.rightSibling; B1 =pos.leftmostChild; B1.rightSibling=pos; pos.leftmostChild=pos.rightmostChild.leftmostChild; } merge(newHeap,B1); } public void Display(){ System.out.print("("); System.out.print(this.root.key); if(this.leftmostChild != null){ this.leftmostChild.Display(); } System.out.print(")"); if(this.rightSibling!=null){ this.rightSibling.Display(); } } }

    Read the article

  • left join without duplicate values using MIN()

    - by Clipper87
    I have a table_1: id custno 1 1 2 2 3 3 and a table_2: id custno qty descr 1 1 10 a 2 1 7 b 3 2 4 c 4 3 7 d 5 1 5 e 6 1 5 f When I run this query to show the minimum order quantities from every customer: SELECT DISTINCT table_1.custno,table_2.qty,table_2.descr FROM table_1 LEFT OUTER JOIN table_2 ON table_1.custno = table_2.custno AND qty = (SELECT MIN(qty) FROM table_2 WHERE table_2.custno = table_1.custno ) Then I get this result: custno qty descr 1 5 e 1 5 f 2 4 c 3 7 d Customer 1 appears twice each time with the same minimum qty (& a different description) but I only want to see customer 1 appear once. I don't care if that is the record with 'e' as a description or 'f' as a description. How could I do this ? Thx!

    Read the article

  • SQL MIN in Sub query causes huge delay

    - by Spencer
    I have a SQL query that I'm trying to debug. It works fine for small sets of data, but in large sets of data, this particular part of it causes it to take 45-50 seconds instead of being sub second in speed. This subquery is one of the select items in a larger query. I'm basically trying to figure out when the earliest work date is that fits in the same category as the current row we are looking at (from table dr) ISNULL(CONVERT(varchar(25),(SELECT MIN(drsd.DateWorked) FROM [TableName] drsd WHERE drsd.UserID = dr.UserID AND drsd.Val1 = dr.Val1 OR (((drsd.Val2 = dr.Val2 AND LEN(dr.Val2) > 0) AND (drsd.Val3 = dr.Val3 AND LEN(dr.Val3) > 0) AND (drsd.Val4 = dr.Val4 AND LEN(dr.Val4) > 0)) OR (drsd.Val5 = dr.Val5 AND LEN(dr.Val5) > 0) OR ((drsd.Val6 = dr.Val6 AND LEN(dr.Val6) > 0) AND (drsd.Val7 = dr.Val7 AND LEN(dr.Val2) > 0))))), '') AS WorkStartDate, This winds up executing a key lookup some 18 million times on a table that has 346,000 records. I've tried creating an index on it, but haven't had any success. Also, selecting a max value in this same query is sub second in time, as it doesn't have to execute very many times at all. Any suggestions of a different approach to try? Thanks!

    Read the article

  • CSS Tables & min-width container?

    - by neezer
    <div id="wrapper"> <div id="header">...</div> <div id="main"> <div id="content">...</div> <div id="sidebar">...</div> </div> </div> #wrapper { min-width: 900px; } #main { display: table-row; } #content { display: table-cell; } #sidebar { display: table-cell; width: 250px; } The problem is that the sidebar isn't always at the right-most part of the page (depending on the width of #content). As #content's width is variable (depending on the width of the window), how to I make it so that the sidebar is always at the right-most part of its parent? Ex. Here's what I have now: <--- variable window width ----> --------------------------------- | (header) | --------------------------------- [content] | [sidebar] | | | | | | | | | | | | | And here's what I want: <--- variable window width ----> --------------------------------- | (header) | --------------------------------- [content] | [sidebar] | | | | | | | | | | | | | Please let me know if you need anymore information to help me with this issue. Thanks! PS - I know I can accomplish this easily with floats. I'm looking for a solution that uses CSS tables.

    Read the article

  • Ordering by a max or a min from another table

    - by Paul Tomblin
    I have a table that consists of a unique id, and a few other attributes. It holds "schedules". Then I have another table that holds a list of all the times each schedule has or will "fire". This isn't the exact schema, but it's close: create table schedule ( id varchar(40) primary key, attr1 int, attr2 varchar(20) ); create table schedule_times ( id varchar(40) foreign key schedule(id), fire_date date ); I want to query the schedule table, getting the attributes and the next and previous fire_dates, in Java, sometimes ordering on one of the attributes, but sometimes ordering on either previous fire_date or the next fire_date. Ordering by the attributes is easy, I just stick an "order by" into the string while I'm building my prepared statement. I'm not even sure how to go about selecting the last fire_date and the next one in a single query - I know that I can find the next fire_date for a given id by doing a SELECT min(fire_date) FROM schedule_times WHERE id = ? AND fire_date > sysdate; and the similar thing for previous fire_date using max() and fire_date < sysdate. I'm just drawing a blank on how to incorporate that into a single select from the schedule so I can get both next and previous fire_date in one shot, and also how to order by either of those attributes.

    Read the article

  • HTML/CSS: Creating a centered div with a min-width

    - by Alessandro Vernet
    I'd like to have on my page a div which is centered and has a certain width, but which extends beyond that width if required by the content. I am doing this with the following: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <style type="text/css"> .container-center { text-align: center; } .container-minwidth { min-width: 5em; display: inline-block; border: 1px solid blue; } </style> </head> <body> <div class="container-center"> <div class="container-minwidth"> a </div> </div> </body> </html> This works great on Firefox/Safari, but not on IE6, which doesn't understand the display: inline-block. Any advice on how to make this work on IE6 as well?

    Read the article

  • CSS challenge: Two background images, centered column with fixed with, min-height 100%

    - by laurent
    In a nutshell I need a CSS solution for the following requirements: Layout: One centered column with fixed width and a minimum height of 100% Two vertically repeated background images behind the centered column, one aligned to the left, one aligned to the right Cross browser compatibility A little more details Today a new requirement for my current web site project came up: A background image with gradients on the left and right side. The challenge is now to specify two different background images while keeping the rest of the layout spec. Unfortunately the (simple) layout somehow doesn't go with the two backgrounds. My layout is basically one centered column with fixed width: #main_container { margin: 0 auto; min-height: 100%; width: 800px; } Furthermore it's necessary to stretch the column to a minimum height of 100%, since there are quite some pages with only little content. The following CSS styles take care of that: html { height: 100%; } body { margin: 0; height: 100%; padding: 0; } So far so good - until the two background image issue arrived... I tried the following solutions Two absolute positioned divs behind the main container One image defined with the body, one with the html CSS class One image defined with the body, the other one with a large div begind the main container With either one of them, the dynamic height solution was ruined. Either the main container didn't stretch to 100% when it was too small, or the background remained at 100% when the content was actually longer

    Read the article

  • Math.max and Math.min outputting highest and lowest values allowed

    - by user1696162
    so I'm trying to make a program that will output the sum, average, and smallest and largest values. I have everything basically figured out except the smallest and largest values are outputting 2147483647 and -2147483647, which I believe are the absolute smallest and largest values that Java will compute. Anyway, I want to compute the numbers that a user enters, so this obviously isn't correct. Here is my class. I assume something is going wrong in the addValue method. public class DataSet { private int sum; private int count; private int largest; private int smallest; private double average; public DataSet() { sum = 0; count = 0; largest = Integer.MAX_VALUE; smallest = Integer.MIN_VALUE; average = 0; } public void addValue(int x) { count++; sum = sum + x; largest = Math.max(x, largest); smallest = Math.min(x, smallest); } public int getSum() { return sum; } public double getAverage() { average = sum / count; return average; } public int getCount() { return count; } public int getLargest() { return largest; } public int getSmallest() { return smallest; } } And here is my tester class for this project: public class DataSetTester { public static void main(String[] arg) { DataSet ds = new DataSet(); ds.addValue(13); ds.addValue(-2); ds.addValue(3); ds.addValue(0); System.out.println("Count: " + ds.getCount()); System.out.println("Sum: " + ds.getSum()); System.out.println("Average: " + ds.getAverage()); System.out.println("Smallest: " + ds.getSmallest()); System.out.println("Largest: " + ds.getLargest()); } } Everything outputs correctly (count, sum, average) except the smallest and largest numbers. If anyone could point me in the right direction of what I'm doing wrong, that would be great. Thanks.

    Read the article

  • Having problem with C++ file handling

    - by caramel1991
    Our lecturer has given us a task,I've attempted it and try every single effort I can,but I still struggle with one of the problem in it,here goes the question: The company you work at receives a monthly report in a text format. The report contains the following information. • Department Name • Head of Department Name • Month • Minimum spending of the month • Maximum spending of the month Your program is to obtain the name of the input file from the user. Implement a structure to represent the data: Once the file has been read into your program, print out the following statistics for the user: • List which department has the minimum spending per month by month • List which department has the minimum spending by month by month Write the information into a file called “MaxMin.txt” Then do a processing so that the Department Name, Head of Department Name, Minimum spending and Maximum spending are written to separate files based on the month, eg Jan, Feb, March and so on. and of course our lecturer does send us a text file with the content: Engineering Bill Jan 2000 15000 IT Jack Jan 300 20000 HR Jill Jan 1500 10000 Engineering Bill Feb 5000 45000 IT Jack Feb 4500 7000 HR Jill Feb 5600 60000 Engineering Bill Mar 5000 45000 IT Jack Mar 4500 7000 HR Jill Mar 5600 60000 Engineering Bill Apr 5000 45000 IT Jack Apr 4500 7000 HR Jill Apr 5600 60000 Engineering Bill May 2000 15000 IT Jack May 300 20000 HR Jill May 1500 10000 Engineering Bill Jun 2000 15000 IT Jack Jun 300 20000 HR Jill Jun 1500 10000 and here's the c++ code I've written ue#include include include using namespace std; struct Record { string depName; string head; string month; float max; float min; string name; }myRecord[19]; int main () { string line; ofstream minmax,jan,feb,mar,apr,may,jun; char a[50]; char b[50]; int i = 0,j,k; float temp; //float maxjan=myRecord[0].max,maxfeb=myRecord[0].max,maxmar=myRecord[0].max,maxapr=myRecord[0].max,maxmay=myRecord[0].max,maxjune=myRecord[0].max; float minjan=myRecord[1].min,minfeb=myRecord[1].min,minmar=myRecord[1].min,minapr=myRecord[1].min,minmay=myRecord[1].min,minjune=myRecord[1].min; float maxjan=0,maxfeb=0,maxmar=0,maxapr=0,maxmay=0,maxjune=0; //float minjan=0,minfeb=0,minmar=0,minapr=0,minmay=0,minjune=0; string maxjanDep,maxfebDep,maxmarDep,maxaprDep,maxmayDep,maxjunDep; string minjanDep,minfebDep,minmarDep,minaprDep,minmayDep,minjunDep; cout<<"Enter file name: "; cina; ifstream myfile (a); //minmax.open ("MaxMin.txt"); if (myfile.is_open()){ while (! myfile.eof()){ myfilemyRecord[i].depNamemyRecord[i].headmyRecord[i].monthmyRecord[i].minmyRecord[i].max; cout << myRecord[i].depName<<"\t"< cout<<"Enter file name: "; cinb; ifstream myfile1 (b); minmax.open ("MaxMin.txt"); jan.open ("Jan.txt"); feb.open ("Feb.txt"); mar.open ("March.txt"); apr.open ("April.txt"); may.open ("May.txt"); jun.open ("Jun.txt"); if (myfile1.is_open()){ while (! myfile1.eof()){ myfile1myRecord[i].depNamemyRecord[i].headmyRecord[i].monthmyRecord[i].minmyRecord[i].max; if (myRecord[i].month == "Jan"){ jan<< myRecord[i].depName<<"\t"< if (maxjan< myRecord[i].max){ maxjan=myRecord[i].max; maxjanDep=myRecord[i].depName;} //if (minjan myRecord[i].min){ // minjan=myRecord[i].min; //minjanDep=myRecord[i].depName; //} for (k=1;k<=3;k++){ for (j=0;j<2;j++){ if (myRecord[j].minmyRecord[j+1].min){ temp=myRecord[j].min; myRecord[j].min=myRecord[j+1].min; myRecord[j+1].min=temp; minjanDep=myRecord[j].depName; }}} } if (myRecord[i].month == "Feb"){ feb<< myRecord[i].depName<<"\t"< //if (minfebmyRecord[i].min){ //minfeb=myRecord[i].min; //minfebDep=myRecord[i].depName; //} for (k=1;k<=3;k++){ for (j=0;j<2;j++){ if (myRecord[j].minmyRecord[j+1].min){ temp=myRecord[j].min; myRecord[j].min=myRecord[j+1].min; myRecord[j+1].min=temp; minfebDep=myRecord[j+1].depName; }}} } if (myRecord[i].month == "Mar"){ mar<< myRecord[i].depName<<"\t"< if (myRecord[i].month == "Apr"){ apr<< myRecord[i].depName<<"\t"< if (minaprmyRecord[i].min){ minapr=myRecord[i].min; minaprDep=myRecord[i].min;} } if (myRecord[i].month == "May"){ may< if (minmaymyRecord[i].min){ minmay=myRecord[i].min; minmayDep=myRecord[i].depName;} } if (myRecord[i].month == "Jun"){ jun<< myRecord[i].depName<<"\t"< if (minjunemyRecord[i].min){ minjune=myRecord[i].min; minjunDep=myRecord[i].depName;} } i++; myfile.close(); } minmax<<"department that has maximum spending at jan "< else{ cout << "Unable to open file"< } sorry inside that code ue#include should has iostream along with another two #include fstream and string,but at here it was treated as html tag,so i can't type it. my problem here is,I can't seems to get the minimum spending,I've try all I can but I'm still lingering on it,any idea??THANK YOU!

    Read the article

  • Design by contract: predict methods needed, discipline yourself and deal with code that comes to min

    - by fireeyedboy
    I like the idea of designing by contract a lot (at least, as far as I understand the principal). I believe it means you define intefaces first before you start implementing actual code, right? However, from my limited experience (3 OOP years now) I usually can't resist the urge to start coding pretty early, for several reasons: because my limited experience has shown me I am unable to predict what methods I will be needing in the interface, so I might as well start coding right away. or because I am simply too impatient to write out the whole interfaces first. or when I do try it, I still wind up implementing bits of code already, because I fear I might forget this or that imporant bit of code, that springs to mind when I am designing the interfaces. As you see, especially with the last two points, this leads to a very disorderly way of doing thing. Tasks get mixed up. I should draw a clear line between designing interfaces and actual coding. If you, unlike me, are a good/disciplined planner, as intended above, how do you: ...know the majority of methods you will be needing up front so well? Especially if it's components that implement stuff you are not familiar with yet. ...keep yourself from resisting the urge to start coding right away? ...deal with code that comes to mind when you are designing the intefaces?

    Read the article

  • Min Length Custom AbstractValidationAttribute and Implementing Castle.Components.Validator.IValidato

    - by CRice
    I see with the Castle validators I can use a length validation attribute. [ValidateLength(6, 30, "some error message")] public string SomeProperty { get; set; } I am trying to find a MinLength only attribute is there a way to do this with the out of the box attributes? So far my idea is implementing AbstractValidationAttribute public class ValidateMinLengthAttribute : AbstractValidationAttribute and making its Build method return a MinLengthValidator, then using ValidateMinLength on SomeProperty public class MinLengthValidator : Castle.Components.Validator.IValidator Does anyone have an example of a fully implemented IValidator or know where such documentation exists?? I am not sure what all the methods and properties are expecting. Thanks

    Read the article

  • ImageMagick - how to enforce min/max heights/widths?

    - by Henryh
    Using ImageMagick, how can I resize an image to have a minimum: height of 150px width of 200px and also have a maximum: height of 225px width of 275px UPDATE: In case it helps, here's a further explanation of what I'm experiencing. I have a buch of images with all different ratio dimensions. Some images have 1:5 height/width ratios. Some have 5:1 height/width ratios. So that I want to do is set that a minimum height/width size for the image but also don't want the image size to be larger than a particular size. If I need to apply white padding to an image to make it fit within my constraint so that I don't have to distort the image, I'd like to do so.

    Read the article

  • HTML + CSS: fixed background image and body width/min-width (including fiddle)

    - by insertusernamehere
    So, here is my problem. I'm kinda stuck at the moment. I have a huge background image and content in the middle with those attributes: content is centered with margin auto and has a fixed width the content is related to the image (like the image is continued within the content) this relation is only horizontally (vertically scrolling moves everything around) This works actually fine (I'm only talking desktop, not mobile here :) ) with a position fixed on the huge background image. The problem that occurs is the following: When I resize the window to "smaller than the content" the background image gets it width from the body instead of the viewport. So the relation between content and image gets lost. Now I have this little JavaScript which does the trick, but this is of course some overhead I want to avoid: $(window).resize(function(){ img.css('left', (body.width() - img.width()) / 2 ); }); This works with a fixed positioned image, but can get a litty jumpy while calculating. I also tried things like that: <div id="test" style=" position: absolute; z-index: 0; top: 0; left: 0; width: 100%: height: 100%; background: transparent url(content/dummy/brand_backgroud_1600_1.jpg) no-repeat fixed center top; "></div> But this gets me back to my problem described. Is there any "script-less", elegant solution for this problem? UPDATE: now with Fiddle The one I'm trying to solve: http://jsfiddle.net/insertusernamehere/wPmrm/ The one with Javascript that works: http://jsfiddle.net/insertusernamehere/j5E8z/ NOTE The image size is always fixed. The image never gets scaled by the browser. In the JavaScript example it get's blown. So don't care about the size.

    Read the article

  • Find min. "join" operations for sequence

    - by utyle
    Let's say, we have a list/an array of positive integers x1, x2, ... , xn. We can do a join operation on this sequence, that means that we can replace two elements that are next to each other with one element, which is sum of these elements. For example: - array/list: [1;2;3;4;5;6] we can join 2 and 3, and replace them with 5; we can join 5 and 6, and replace them with 11; we cannot join 2 and 4; we cannot join 1 and 3 etc. Main problem is to find minimum join operations for given sequence, after which this sequence will be sorted in increasing order. Note: empty and one-element sequences are sorted in increasing order. Basic examples: for [4; 6; 5; 3; 9] solution is 1 (we join 5 and 3) for [1; 3; 6; 5] solution is also 1 (we join 6 and 5) What I am looking for, is an algorithm that solve this problem. It could be in pseudocode, C, C++, PHP, OCaml or similar (I mean: I woluld understand solution, if You wrote solution in one of these languages). I would appreciate Your help.

    Read the article

  • scheme basic loop

    - by utku
    I'm trying to write a scheme func that behaves in a way similar to a loop. (loop min max func) This loop should perform the func between the range min and max (integers) -- one of an example like this (loop 3 6 (lambda (x) (display (* x x)) (newline))) 9 16 25 36 and I define the function as ( define ( loop min max fn) (cond ((>= max min) ( ( fn min ) ( loop (+ min 1 ) max fn) ) ) ) ) when I run the code I get the result then an error occur. I couldn't handle this error. (loop 3 6 (lambda (x) (display(* x x))(newline))) 9 16 25 36 Backtrace: In standard input: 41: 0* [loop 3 6 #] In utku1.scheme: 9: 1 (cond ((= max min) ((fn min) (loop # max fn)))) 10: 2 [# ... 10: 3* [loop 4 6 #] 9: 4 (cond ((= max min) ((fn min) (loop # max fn)))) 10: 5 [# ... 10: 6* [loop 5 6 #] 9: 7 (cond ((= max min) ((fn min) (loop # max fn)))) 10: 8 [# ... 10: 9* [loop 6 6 #] 9: 10 (cond ((= max min) ((fn min) (loop # max fn)))) 10: 11 [# #] utku1.scheme:10:31: In expression ((fn min) (loop # max ...)): utku1.scheme:10:31: Wrong type to apply: #<unspecified> ABORT: (misc-error)

    Read the article

  • MySQL - how to retrieve columns in same row as the values returned by min/mx

    - by Gala101
    I couldn't frame the Question's title properly.. Suppose a table of weekly movie Earnings as below, MovieName MovieGross WeekofYear Year So how do I get the names of top grossers for each week of this year If I do select MovieName , Max(MovieGross) , WeekofYear from earnings where year = 2010 group by WeekofYear; Then obviously query wont run, select Max(MovieName) , Max(MovieGross) , WeekofYear from earnings where year = 2010 group by WeekofYear; would just give movies starting with lowest alphabet Is using group-concat and then substring-index the only option here? select substring_index(group_concat(MovieName order by MovieGross desc),',',1), Max(MovieGross) , WeekofYear from earnings where year = 2010 group by WeekofYear ; Seems clumsy.. Is there any better way of acieveing this?

    Read the article

  • Setting a min/max zoom for Bing maps in Silverlight

    - by Boone
    I am using the Silverlight sdk for Bing Maps. I have my map, I have my PushPins all mapped out. Now I want to disable the user from zooming out so far they see the whole world and keep it constricted to the just the US. It would be nice if there was something simple like Map.MaxZoom but there is not. Any help?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >