Search Results

Search found 3047 results on 122 pages for 'subset sum'.

Page 65/122 | < Previous Page | 61 62 63 64 65 66 67 68 69 70 71 72  | Next Page >

  • C problem, left of '->' must point to class/struct/union/generic type ??

    - by Patrick
    Hello! Trying to understand why this doesn't work. I keep getting the following errors: left of '-nextNode' must point to class/struct/union/generic type (Also all the lines with a - in the function new_math_struct) Header file #ifndef MSTRUCT_H #define MSTRUCT_H #define PLUS 0 #define MINUS 1 #define DIVIDE 2 #define MULTIPLY 3 #define NUMBER 4 typedef struct math_struct { int type_of_value; int value; int sum; int is_used; struct math_struct* nextNode; } ; typedef struct math_struct* math_struct_ptr; #endif C file int get_input(math_struct_ptr* startNode) { /* character, input by the user */ char input_ch; char* input_ptr; math_struct_ptr* ptr; math_struct_ptr* previousNode; input_ptr = &input_ch; previousNode = startNode; /* as long as input is not ok */ while (1) { input_ch = get_input_character(); if (input_ch == ',') // Carrage return return 1; else if (input_ch == '.') // Illegal character return 0; if (input_ch == '+') ptr = new_math_struct(PLUS, 0); else if (input_ch == '-') ptr = new_math_struct(MINUS, 0); else if (input_ch == '/') ptr = new_math_struct(DIVIDE, 0); else if (input_ch == '*') ptr = new_math_struct(MULTIPLY, 0); else ptr = new_math_struct(NUMBER, atoi(input_ptr)); if (startNode == NULL) { startNode = previousNode = ptr; } else { previousNode->nextNode = ptr; previousNode = ptr; } } return 0; } math_struct_ptr* new_math_struct(int symbol, int value) { math_struct_ptr* ptr; ptr = (math_struct_ptr*)malloc(sizeof(math_struct_ptr)); ptr->type_of_value = symbol; ptr->value = value; ptr->sum = 0; ptr->is_used = 0; return ptr; } char get_input_character() { /* character, input by the user */ char input_ch; /* get the character */ scanf("%c", &input_ch); if (input_ch == '+' || input_ch == '-' || input_ch == '*' || input_ch == '/' || input_ch == ')') return input_ch; // A special character else if (input_ch == '\n') return ','; // A carrage return else if (input_ch < '0' || input_ch > '9') return '.'; // Not a number else return input_ch; // Number } The header for the C file just contains a reference to the struct header and the definitions of the functions. Language C.

    Read the article

  • Weighted random numbers in MATLAB

    - by yuk
    How to randomly pick up N numbers from a vector a with weight assigned to each number? Let's say: a = 1:3; % possible numbers weight = [0.3 0.1 0.2]; % corresponding weights In this case probability to pick up 1 should be 3 times higher than to pick up 2. Sum of all weights can be anything.

    Read the article

  • What is the result of this SQL query?

    - by Martin
    I'm working on a mock exam paper at the moment, however I have no set of correct answers and I'm not sure what the correct answer of this SQL query is. Given a table: foo, bar a , 1 b , 3 a , 2 c , 1 and the query: SELECT foo, sum(bar) FROM table GROUP BY foo The two ways I can see this going are either: a 3 a 3 b 3 c 1 or a 3 b 3 c 1 Thanks.

    Read the article

  • How to define a history chart in crystal reports .net (2008)?

    - by hp
    Hi, I want to display a Bar Chart in a Report that shows the sum of a measure grouped by month for the last 24 month. The months that do not have any tuples do not show up in the graph. I do not want that. I want exactly 24 groups/bars that are 0 if there are no tuples. What is the best way to do this? thanks

    Read the article

  • Which is the fastest idiomatic way to add all vectors (in the math sense) inside a Scala list?

    - by davips
    I have two solutions, but one doesn't compile and the other, I think, could be better: object Foo extends App { val vectors = List(List(1,2,3), List(2,2,3), List(1,2,2)) //just a stupid example //transposing println("vectors = " + vectors.transpose.map (_.sum)) //it prints vectors = List(4, 6, 8) //folding vectors.reduce { case (a, b) => (a zip b) map { case (x, y) => x + y } } //compiler says: missing parameter type for exp. function; arg. types must be fully known }

    Read the article

  • Does F# have an equivalent to Haskell's take?

    - by McMuttons
    In Haskell, there is a function "take n list" which returns the first n elements from a list. For example "sum (take 3 xs)" sums up the first three elements in the list xs. Does F# have an equivalent? I expected it to be one of the List-functions, but I can't spot anything that seems to match.

    Read the article

  • MYSQL Query using subquery

    - by Michael Quiles
    Cant get this to work can any one help. List the part number, part description, and on_hand value of each part whose number of units on hand is more than the average number of units onhand for all parts use a subquery? SELECT PART_NUM, DESCRIPTION, SUM(ON_HAND * PRICE) ON_HAND_VALUE FROM PART; WHERE MAX(ON_HAND); (AVG(ON_HAND) > ON_HAND);

    Read the article

  • Type Mismatch using VBScript to create Pivot Table/Chart

    - by Rodricks
    I get Run time error:Type mismatch for the following code: Dim Field Field="Gen8" '''' ============================================================================== EXCEL Sheet '==============Errors -Stacked Chart by Year and Week --ALL WEEKS ''''=================================================== objExcel.ActiveWorkbook.Worksheets.Add SheetNumber = SheetNumber ' add adds in front so sheetnumber stays 1 objExcel.Sheets(SheetNumber).Select objExcel.Sheets(SheetNumber).Activate objExcel.Sheets(SheetNumber).Name = "YRWk" SheetName = "SYS_Product_YRWeeks" '============== strSQLCustomers = "select isnull(AB.Week,D.Week_Num) AS YRWk,ISNULL(AB.UnCorrectable,0) as UE," & _ "isnull(AB.Correctable,0) as CE, isnull(AB.SYS_Product,'" & Field & "'" & _ ") as SYS_Product from AHS_Dates D Left Join (select * from P_tot where " & _ "SYS_Product = '" & Field & "'" & _ " ) AB on AB.Year_=D.Year_ and AB.Week=D.Week_Num order by YRWk" FetchData2.Open strSQLCustomers, openConnection, adOpenStatic, adLockReadOnly If FetchData2.RecordCount > 0 Then **objExcel.ActiveWorkbook.Connections.Add SheetName, "", _ Array(Array( _ "ODBC;DRIVER=SQL Server Native Client 10.0;SERVER=" & sServerIP & ";TimeOut=5000000; Trusted_Connection=Yes;Integrated Security=SSPI;" _ ), Array("DATABASE=" & sDataBaseName & ";")), Array(strSQLCustomers), 2** objExcel.ActiveWorkbook.PivotCaches.Create(SourceType:=xlExternal, SourceData:= _ objExcel.ActiveWorkbook.Connections(SheetName), Version:= _ xlPivotTableVersion14).CreatePivotTable TableDestination:=objExcel.Sheets(SheetNumber).Name & "!R3C7", _ TableName:="PivotTable" & SheetNumber, DefaultVersion:=xlPivotTableVersion14 Set ws = objExcel.ActiveWorkbook.Worksheets(objExcel.Sheets(SheetNumber).Name) objExcel.Cells(3, 7).Select ws.Shapes.AddChart.Select objExcel.ActiveWorkbook.ActiveChart.ChartType = xlAreaStacked objExcel.ActiveWorkbook.ActiveChart.SetSourceData Source:=ws.Range(objExcel.Sheets(SheetNumber).Name & "!$G$3:$I$20") With ws.PivotTables("PivotTable1").PivotFields("SYS_PRoduct") .Orientation = xlColumnField .Position = 1 End With With ws.PivotTables("PivotTable1").PivotFields("YRWk") .Orientation = xlRowField .Position = 1 End With ' With ws.PivotTables("PivotTable1").PivotFields("Year_") ' .Orientation = xlRowField ' .Position = 2 ' End With objExcel.ActiveWorkbook.ActiveChart.ChartTitle.Text = " Errors by Week and Year -ALLWEEKS" ws.PivotTables("PivotTable1").AddDataField ws.PivotTables( _ "PivotTable1").PivotFields("UE"), "Sum of UnCorrectable", xlSum ws.PivotTables("PivotTable1").AddDataField ws.PivotTables( _ "PivotTable1").PivotFields("CE"), "Sum of Correctable", xlSum End If ''MsgBox (FetchData2.RecordCount) FetchData2.Close I have used the same pivot chart + table in other slides. The problem I think is the query length My question: 1.Is there a better way for me to access the query results. Would appreciate the steps if any. 2.If I can make it a procedure how do I modify the pivot chart/table creation. Thanks. The query results with all 52 weeks: Week UE CE SYS_Product(or Field) 1 0 0 Gen8 2 0 0 Gen8 3 0 0 Gen8 4 0 0 Gen8 5 0 0 Gen8 6 0 0 Gen8

    Read the article

  • need help while working on a website

    - by EqEdi
    I'm working for a website where i need to sum functionality related to sales I'm very new to the website stuff and found many things on net but don't knew what to follow. Can anybody suggest me some good tutorials which i can follow to create my website The things which i am going to work on as: saving customer information to data base using saved customer information, placing order generating bills and invoices and downloading it in pdf file format sending mails to customer with those invoice as attachments

    Read the article

  • percentage formula in crystal report 8.5

    - by sathik
    am doing one project using vb6.0+access+crystal report8.5 some error occur during the crystal report. Query Name seqquery: SELECT segment_trans.division_name, sum(segment_trans.Total_value) AS total, division_master.Target FROM segment_trans, division_master GROUP BY segment_trans.division_name, division_master.Target; crystal report percentage formula: {(seqquery.total * 100) / seqquery.Target } Error: This field name is not known. note: Total_value and Target field's datatype "Text" how to solve this ? please help me. Thanks Sathik

    Read the article

  • Need help Linq query join + count + group by

    - by user233540
    I have two table First table BID Town 1 ABC 2 ABC2 3 ABC Second Table PID BID AmountFirst AmountSecond AmountThird Minority 1__ 1___ 1000_____ 1000________ 1000_____ SC 2__ 2___ 2000_____ 1000_______ 2000_____ ST 3__ 3___ 1000____ 1000_______ 1000_______ SC BID is foreign key in Second table. I want sum AmountFirst + AmountSecond +AmountThird for individualTown e.g for ABC town answer should be : 6000 (summation of PID 1 and PID 2) I want Linq query for this..Please help

    Read the article

  • What are :+ and &+ in ruby?

    - by Valentin Vasilyev
    I've seen these several times but I can't figure out how to use them. The pickaxe says that these are special shortcuts but I wasn't able to find the syntactical description. I've seen them in such contexts: [1,2,3].inject(:+) to calculate sum for example.

    Read the article

  • Order a foreach, by the value of a calculation of values in the array

    - by Mark
    I have an array as follows: $players = array( $player = array( 'name' => 'playername', 'speed' => '10', 'agility' => '10', 'influence' => '10' ) etc Then I calculate a $score, based on the sum of speed, agility and influence. $score = $p['speed'] + $p['agility'] + $p['influence']; How can I loop through my array, but order the results from highest to lowest $score? PS- http://pastebin.com/eUEQ5y4u

    Read the article

  • Problem with python !!

    - by the-ifl
    Well I Have a little problem , i want to Get the sum of all numbers below to 1000000 , and who has 4 Divisors... I Try but i have a problem : http://pastebin.com/bhiDb5fe

    Read the article

  • Count of Sums possibly using group_by

    - by Daniel Johnson
    Say you have a user table and an order table which references user (user has_many orders) and contains an item count field. How could you efficiently ask "how many uses ordered how many items?" That is, to generate something along the lines of: Number of users | sum of items ------------------------------- 5 users | 1 item 4 users | 5 items 1 user | 7 items Thanks in advance.

    Read the article

  • LINQ to SQL selecting fields

    - by user3686904
    I am trying to populate more columns in the query below, could someone assist me? QUERY: var query = from r in SQLresults.AsEnumerable() group r by r.Field<string>("COLUMN_ONE") into groupedTable select new { c1 = groupedTable.Key, c2 = groupedTable.Sum(s => s.Field<decimal>("COLUMN_TWO")), }; How could I get a column named COLUMN_THREE in this query ? Thanks in advance

    Read the article

  • How Can I Implement This Function?

    - by hoora
    I'm a beginner and I want to write Java code in eclipse. This program takes two LinkedLists of integers (for example, a and b) and makes a LinkedList (for example d) in which every element is the sum of elements from a and b. However, I can't add these two elements from a and b because they are Objects Example: a=[3,4,6,7,8] b=[4,3,7,5,3,2,1] ------ d=[7,7,13,12,11,2,1]

    Read the article

  • c programming Language [closed]

    - by ash89
    Write a program in C program to find the sum of the following: The input contain a sequence of two or more positive integers terminated by -1. Write a piece of code to count the ‘incidences’ in this sequence (i.e. the number of pairs of equal, adjacent numbers). For example, the following sequence contains 4 incidences: 4 2 9 9 3 7 7 7 3 3 -1

    Read the article

  • Problem with a Python function

    - by the-ifl
    Well I have a little problem. I want to get the sum of all numbers below to 1000000, and who has 4 divisors... I try, but i have a problem because the GetTheSum(n) function always returns the number "6"... This is my Code : http://pastebin.com/bhiDb5fe

    Read the article

< Previous Page | 61 62 63 64 65 66 67 68 69 70 71 72  | Next Page >