homework

solving problems recursively in C

Our professor gave us the following assignment: A "correct" series is one inwhich the sum of its members equals to the index of its first member. The program is supposed to find the length of the LONGEST "correct" series within a series of n numbers. for example: if the input series would be arr[4]={1, 1, 0, 0} the output (long...

Data from array to sql

I'm making a webshop for a school asignment and therfore i needed to make a shopping cart. In the shopping cart the data is storred in an array. The code for when I echo it out is <tr> <td><?php echo $row['Navn'];?></td> <td><input type="text" name="antall-<?php echo $row['id_produkt'];?>" size="5" value=" <?php echo $_SESSION['han...

retrievind date in asp.net

Hello frineds, I need to retrieve the current date in asp.net and then compare that with the date given by the user in textbox1.text(mm/dd/yyyy format), if date date given is greater than current date then error else add 4months2days with that date and display it in textbox2.text. help me please, thanking you guys, Indranil ...

How to "scan" a website (or page) for info, and bring it into my program?

Well, I'm pretty much trying to figure out how to pull information from a webpage, and bring it into my program (in Java). For example, if I know the exact page I want info from, for the sake of simplicity a Best Buy item page, how would I get the appropriate info I need off of that page? Like the title, price, description? What woul...

C++ - How to efficiently find out if any string in a vector can be assembled from a set of letters

Hello, everyone! I am implementing a text-based version of Scrabble for a college project. I have a vector containing around 400K strings (my dictionary), and, at some point in every turn, I'm going to have to check if there's still a word in the dictionary which can be formed with the pieces in the player's hand. I'm checking if the p...

Help With Lisp Code for a Binary Tree

I have (setq l2 '(1 (2 b (c 1 b))(a (1 2) d))) (defun drumuri (l3) (cond ((atom l3) (cons l3 nil)) (t (append (cons (car l3) nil) (drumuri (cadr l3)) (cons (car l3) nil) (drumuri (caddr l3)))))) (drumuri l2) and it gives me: Break 2 [4]> DRUMURI Break 2 [4]> (1 2 B 2 ...

mv() while reading

on Linux ext3 filesystem, what happens if mv() is called on the same file (file descriptor) while reading the file? It is actually an exam question and I can only say something like: CPU traps OS for interrupt handling etc, etc. I would appreciate if OS guys out there can help me out, please :D ...

Simplest way of creating java next/previous buttons

I know that when creating buttons, like next and previous, that the code can be somewhat long to get those buttons to function. My professor gave us this example to create the next button: private void jbtnNext_Click() { JOptionPane.showMessageDialog(null, "Next" ,"Button Pressed", JOptionPane.INFORMATION_MESSA...

Help implementing the All Nearest Smaller Values algorithm

http://en.wikipedia.org/wiki/All_nearest_smaller_values. This is the site of the problem and here is my code, but I have some trouble to implement it: import java.util.*; public class stack{ public static void main(String[]args){ int x[]=new int[]{ 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 }; Stack<Int...

program not working as expected!

Can anyone just help spot why my program is not returning the expected output. This is related to my previous question. I am passing a vector by reference; I want to see whats in the container before I copy them to another location. If you remove comments on loadRange, youu will see bids are generated by the trader. #include <iostream> ...

Updating List Elements, Haskell

I have homework where I am to update a list using a function that takes two elements and returns a value of part of the first element given in the function. So it's required to update the entire listing by going through each element and update its value by applying the function against all other elements in the list (including itself). ...

Sorting in Hash Maps in Java

I'm trying to get familiar with Collections. I have a String which is my key, email address, and a Person object (firstName, lastName, telephone, email). I read in the Java collections chapter on Sun's webpages that if you had a HashMap and wanted it sorted, you could use a TreeMap. How does this sort work? Is it based on the compare...

How to use Comparator in Java to sort

I learned how to use the comparable but I'm having difficulty with the Comparator. I am having a error in my code: Exception in thread "main" java.lang.ClassCastException: New.People cannot be cast to java.lang.Comparable at java.util.Arrays.mergeSort(Unknown Source) at java.util.Arrays.sort(Unknown Source) at java.util.Collections....

Passing a comparator syntax help in Java

I've tried this a couple ways, the first is have a class that implements comparator at the bottom of the following code. When I try to pass the comparat in sortListByLastName, I get a constructor not found error and I am not sure why import java.util.*; public class OrganizeThis implements WhoDoneIt { /** Add a person to the ...

help with multiplying polynomials in lisp

for example: (3x2 - 5x + 2)(7x + 1) and you simplify it like this: ((3 2)(-5 1)(2 0))((7 1)(1 0)) ((21 3)(3 2)(-35 2)(-5 1)(14 1)(2 0)) (21 3)(32 2)(9 1)(2 0) and you get this answer: 21x3 + 32x2 + 9x + 2 i need this solution in lisp please help ...

Knight's tour / recursion

Hey, I'm trying to learn a little bit more about recursion but somehow I can't solve the knight's tour and I'm hoping someone can point out my logic error. class main { static int fsize = 5; // board size (5*5) static int board[][] = new int[fsize][fsize]; static int[] move_x = {1, 2, 2, 1, -1, -2, -2, -1}; // possible move...

How to put theory into practise

I like to read alot of IT books e.g programming / functional. But the problem is that after reading I cannot find reasons to put it into practise and I soon forget what I read. Any advise? ...

Need help with this question: Write Java code which reads numbers from the keyboard.....

Write Java code which reads numbers from the keyboard until zero is entered. Only the positive numbers entered are to be added to a variable-sized collection. This is what I have so far: import java.lang.*; import java.util.*; import java.io.*; import java.net.*; public class Demo1App extends Object { public static void main(String[]...

implementing interface

hello guys so i have this assignment that i need to implement interface to go over an ArrayList and sort it (ascending or descnding).I dont want "the" answer i just need some suggestions on my approach and why i get this error Exception in thread "main" java.lang.ClassCastException: Week7.Check cannot be cast to java.lang.Comparable a...

Prime Numbers Code Help

Hello Everybody, I am suppose to "write a Java program that reads a positive integer n from standard input, then prints out the first n prime number." It's divided into 3 parts. 1st: This function will return true or false according to whether m is prime or composite. The array argument P will contain a sufficient number of primes to d...