homework

Sorting with c++ algorithm

I want to sort chopsticks by weight and I want the matching pair of chopstick at the end of program. Should I use sort algorithm? I want to sort it by weight means (e.g 110, 90, 110, 90) so in this case I got 2 pair. One having weight 90 and other having weight 110, but how can I track that? I know I have to use counter but how I don not...

UML diagram generator in Visual Studio 2010

My professor asked us to generate UML for next homework. We are using Visual studio 2010 for c++ programming. I tried to work on it but I could not figure out, I went to Architecture-> Windows -> UML Model Explorer but don't understand where to go next. Is UML generator creates UML automatically or it will just give bunch of boxes to fil...

Quick/Simple Regex/Regular Language Clarification

Hey all, I feel like a moron posting such simple questions on here, but the knowledge base of this site is just amazing. Thanks for your understanding. Concerning a question about finding the minimum pumping length (concerning the pumping lemma for regular languages) of a regular expression: Regular Expression R = 1011 (over the alph...

Page fault count within two arrays?

Homework: Consider the two-dimensional array A: int A[][] = new int[200][200]; where A[0][0] is at location 500 in a paged memory system with pages of size 500 (a little unrealistic -- not 512). A small process that manipulates the matrix resides in page 0 (locations 0 to 499). Thus, every instruction fetch will be from an ins...

Creating a high and low game in python and need a lot of help!

Here is the Pseudocode Print instructions to the user Start with the variables high = 1000, low = 1, and tries = 1 While high is greater than low Guess the average of high and low Ask the user to respond to the guess Handle the four possible outcomes: If the guess was right, print a message that tries guesses were required and quit th...

How to do graph coverage testing for a complex class that require a lot of set up ?

Ok I have a class with methods that has high McCabe Cyclomatic Complexity. I have a school assignment to do graph coverage of that beast. The real problem is that it's hard to set up the inputs. Concretely, the program is a mario platform game and the job of the class is to compute mario states. There is a procedure that move mario and ...

Anyone can crash this code segment?

if the end user input anything else except 1, the program will exit, it will not be considered as crash ###substraction program print 'Subtraction program, v0.0.3 (beta)' loop = 1 while loop == 1: try: a = input('Enter a number to subtract from > ') b = input('Enter the number to subtract > ') except NameError: ...

1-D into 2-D array

A program in c++ that accept an integer array and its size as arguments and assign the elements into a 2-D array of integers. for ex: if the array is 1,2,3 The resultant 2-D array is given by 1 2 3 1 2 0 1 0 0 ...

Linked List in C

I am having some trouble running this linked list implementation (containing words as data). Problem is when I try to print the words (that I inserted) in the Linked List,I get nothing. What am I doing wrong, breaking my head over this? I hope it's not something silly. Anyway here's the code - typedef struct node { void *data; s...

Character arrays, and pointers how to use strtok and strcmp.

I'm writing a linux shell for my operating systems class. I've knocked out the majority of it but I'm stuck on simple string comparisons. I've everything I can think of. strcmp should take in \0 terminated strings and return 0 for equal but that doesn't seem to be working and even stepping through the array and checking each char isn'...

What is vendor independence?

hi all of you, Can you please help me to know the meaning of vendor independence that provided by Free and open source software (FOSS)? ...

Question about web programming, maps to be specific

The prof gave us an assigment to finish in the next couple of months, we have to write a web app that is basically a mapping system for a floor of a building. Like a very very simple version of google maps, people need to be able to look up a room and be able to get directions from one part of the floor to another. I have never done any ...

How can I check if a signed integer is positive?

Using bitwise operators and I suppose addition and subtraction, how can I check if a signed integer is positive (specifically, not negative and not zero)? I'm sure the answer to this is very simple, but it's just not coming to me. ...

Why does this C++ program print irrelevant characters?

Hey i am new to programming in C++, and i get the hang of it but i got stuck on this one simple problem i am suppose to create a shift cipher using the letters A-Z and shifting them 3 places, i get everything but when i do my output i get extra letters that are unneeded like "|[|" i know i have to put a terminator and i did but doesn't s...

Matching data from text file with user input in Java

I need to retrieve the PIN from a notepad file (below) and check it with the PIN which the user has typed. I have tried this for days, but so far the solution that I have come up with gives me the correct output only when I type the full row (i.e. 1598 01-10-102203-0 95000). Also it displays the "Invalid PIN" for each and every reco...

[SOLVED] Sudoku solver keeps getting stuck for some reason...

So I had to write a program for a computer project for high school and I thought of doing a sudoko solver. The 'solve' algorithm is implemented like this:- For any points where only one element 'fits' looking at rows, columns, 3x3 set, put that number in. Do this repeatedly till it can't be done anymore. This is seen in the 'singleLeft...

Help needed to complete my homework

My teacher gave me an assignment: Write a program to input retail price of a product. If a 6.5% discount is given to a customer, then find and print the selling price. Additional Details: I'm new to programming. I haven't learned any functions except printf() and Scanf(). Please write the program using only these functions. I have d...

Check if string has all the letters of the alphabet

What would be the best logic to check all the letters in a given string. If all the 26 letters are available in the provided string, I want to check that and perform so ops. eg. Pack my box with five dozen liquor jugs. Would using a Hash be useful? Or using a bit map? or any other way? BTW my code would be in Java. ...

socket in python

hello ,,, i tried to do client and server and look what i do #Server import socket Host='' Port=305 OK=socket.socket() OK.bind((Host,Port)) OK.listn(1) OK.accept() and another one for client #Client impot socket Host='192.168.1.4' Port=305 OK=socket.socket() OK.connect((Host,Port)) First thing : for now every thing is ok but i w...

Counting occurences of unique letters in a string

Let's say I have the string "UNDERSTAND". Now let's say I want to count the occurrences of each letter in the string. So from my example I would want something like this, U - 1 N - 2 D - 2 E - 1 R - 1 S - 1 T - 1 A - 1 How can I do this? ...