homework

How is a symbol table helpful in translating one language to another

In compiler class we made a parser for a made up language that is a simplified version of C. All the parser does is make a symbol table based on the input and exit with an error message if the syntax is incorrect. Now we need to take an input file that is written in this language, and convert it into mips code (actually spim code which ...

How do I fix this stack overflow error?

So I have what I think is pretty good code for a sudoku solver in java but I need some help with this method. It gives me a stack overflow when I embed it in a main method. The problem is that my method doesn't know how to turn around and fix its mistakes. I need a boolean flag (one that, unlike the one used in the code below, actually w...

[C Program] How to generate a new random number and transpose the matrix?

Thanks for all helped me before. But I still have some questions about the program. How to generate a new random number while the new random number is equal to the previous random number? Also how to transpose the matrix? #include "stdafx.h" #include "stdlib.h" #include "time.h" int _tmain(int argc, _TCHAR* argv[]) { int nu...

A further question about calculating average "distance" between the corresponding content in two files.

Now my program generates two data files. a.txt and b.txt Take a.txt as an example, it's content just like this: 0,0 0,1 1,0 -3,1 1,-2 1,3 ...... b.txt is similar with a.txt. Now, I hope to find out average distance between the corresponding content in a and b file. In other words, for example, if b.txt like this: 0,0 1,1 1,2 -3,1 ...

suggestion required related to rewriting and string manipulation

Hi everyone , I had to read from a file and for each data between delimiter i need to remove the white space and i have written the following program in jython When i am trying to rewrite ,its rewriting at the end of source file. filesrc = open('c:/FILE/split_doc.txt','r+') for list in filesrc.readlines(): #split the records by...

Implementing a z buffer in a software rasterizer

Hello, as a homework assignment, we're writing a software rasterizer. I've noticed my z buffering is not working as well as it should, so I'm trying to debug it by outputting it to the screen. (Black is near, white is far away). However, I'm getting peculiar values for the z per vertex. This is what I use to transform the points: floa...

A function in Scheme to replace all occurences of an element in a list with another element

Hi! I am able to delete the element from a list, but I have no idea how to write a function in Scheme to replace all occurences of an element in a list with another element. Any help will be appreciated. ...

Searching a file.

This is in reference to a question I posted yesterday http://stackoverflow.com/questions/1925284/searching-a-file-in-3-different-ways I just require help now on two things, searching a file and and printing the line a search result is found on and all the lines after it to the end of the file. Lastly i need help on coding were i search...

Why is my recursiveMinimum function not working?

#include <iostream> using namespace std; int recursiveMinimum(int [], int n); int main () { int theArray[3] = {1,2,3}; cout << recursiveMinimum(theArray, 0); cout << endl; return 0; } // pass in array and 0 to indicate first element // returns smallest number in an array int recursiveMinimum (int anArray[], int n) /...

design exercise preferably using mfc

i was told to design a paintbrush program in 2 variation , one that uses lots of space and little cpu and the other vice versa. the idea (as i was told- so not sure) is somehow to save the screen snapshots versus saving XOR maps (which i have no idea what it means) who represent the delta between the painting. can someone suggest a wa...

Searching for text in a file.

hi there got a couple of probs, say in my text file i have: abase abased abasement abasements abases This coding below is meant to find a word in a file and print all the lines to the end of the file. But it doesnt it only prints out my search term and not the rest of the file. search_term = r'\b%s\b' % search_term for line in op...

Printing Lines in a File.

So here's the problem I have, I can find the Search Term in my file but at the moment I can only print out the line that the Search Term is in. (Thanks to Questions posted by people earlier =)). But I cannot print out all the lines to the end of the file after the Search Term. Here is the coding I have so far:- search_term = r'\b%s\b'...

xml catalogue help

hi, need help on an xml task, im new to xml. the task is to build a xml catalogue which has 4 genres of music with two examples know i have manged to make that but im having difficulty write the code for the xsl stylesheet ...

Sorting an array with minimal number of comparisons

I need some help with my CS homework. I need to write a sorting routine that sorts an array of length 5 using 7 comparisons in the worst case (I've proven that 7 will be needed, because of the height of the decision tree). I considered using the decision tree 'hard-coded', but that means the algorithm is really complicated and was hinte...

maximal value in recursion

Hi, I have this homework assignment: Let Pi be the element of arr in index i. We say an index i is ‘well-placed’ if there exists an index j (j >= i) so that summing the elements in Pi Pi+1 … Pj yields the index i. In other words, an index is ‘well-placed’ if a sequence of elements beginning at that index yields the index when summed....

File searching: TypeError

Hi there, Im trying to search a file where the the line containing the search term is found and printed along with a number of lines before and after the search term defined by the user. The coding i have so far is: f = open(f, 'r') d = {} for n, line in enumerate(f): d[n%numb] = line.rstrip() if search_term in line: fo...

related to abstract class reference holding object of its derived class

class A is abstract and class B extends class A now class A reference can hold object of class B,that is A aObj = new B(); and assume class B has some extra methods.... like class A { public show(); } class B extends A { public show(){} public method1(){} private method2(){} } now tell me what things variable aObj can access from c...

sql Query help - little help

Short database description "Ships": The database of naval ships that took part in World War II is under consideration. The database has the following relations: Classes(class, type, country, numGuns, bore, displacement) Ships(name, class, launched) Battles(name, date) Outcomes(ship, battle, result) Ships in classes are arranged to a...

Word occurrence in a String(word count)

Hello. Im stuck on writing Word occurrence in a string. I got some tip(in task notes) to use is compareToIgnoreCase. so I tried something like this: splitwords = StringCont.split("\\s"); for(int i=0; i<splitwords.length; i++) { if(splitwords[1].compareToIgnoreCase(splitwords[i]) == 0) splitcount++; } It is of course just w...

Mathematical Expression evaluation preferably without using stacks or queues

Given the allowed operators of +, /, -, *, and given a user inputted list of single digit numbers (any length allowed), how can I output all possible combinations of mathematical expressions (and the resulting values) that can be formed with the numbers and the given constant set of operators? Also to allow for scalability, for example,...