homework

power of an integer in c++

Hi! I need to get the result from pow(a,b) as an integer (both a and b are integers too). currently the calculations where (int) pow( (double)a, (double)b) is included are wrong. Maybe someone can help with a function that does the pow(a,b) with integers and returns an integer too? But here is the odd part: I made my script in Linux wi...

.NET Function to determine first, last day, etc.

Does anyone know of a good piece of C# code or assembly that supports the following: Find the 1st Tuesday of June 2012 Find the last Friday of March 2008 Find every Saturday in January 2013 Find the 3rd Friday in July 2009 Find every Saturday over the next 3 months Find every day in March 2018 The results should come back as...

Convert a-z to print out abcdef....z?

I want to be able to have a user input a-z or c-z or c-p or whatever and have it return the actual letters between those two. I figured I would have to use ASCII numbering so I could use these steps: 1) Look for '-', if true 2) Look at first char that was input(char a in a-z), find ASCII # 3) Look at last char that was input (char z ...

How to end a loop early in C?

I have a basic C program that produces a number and the user has to guess it (yup, you've already called it: homework). I am able to get pretty much all of it so I am kinda proud, but I open to any errors I have made of course I am still learning. My main two questions are How can I end this program early once the user has selected the...

Algorithm for fair distribution of numbers into two sets.

Hello, Given a set of n numbers (1 <= n <= 100) where each number is an integer between 1 and 450,we need to distribute those set of numbers into two sets A and B, such that the following two cases hold true: The total numbers in each set differ by at most 1. The sum of all the numbers in A is as nearly equal as possible to the sum of...

UNIX System call to register A BACKGROUND PROCESS

I am writing my own shell as part of course assignment. So I need to support background jobs. I am maintaining data strutures for job id and background jobs. But I need to tell kernel also that this is background process so that there is only one terminal foreground process. Till now I am handling background jobs at my program level. W...

c++ tokenize a string and include delimiters

I'm tokening with the following, but unsure how to include the delimiters with it. void Tokenize(const string str, vector<string>& tokens, const string& delimiters) { int startpos = 0; int pos = str.find_first_of(delimiters, startpos); string strTemp; while (string::npos != pos || string::npos != startpos) { ...

Program Runtime HW Problem

An algo takes .5 ms seconds for an input size of 100, how long will it take to run if the input size is 500 and the program is O(n lg(n))? My book says that when the input size doubles, n lg(n), takes "slightly more than twice as long". That isn't really helping me much. The way I've been doing it, is solving for the constant...

Please help me with this program to parse a file into an XML file.

To parse an input text file and generate a) an XML file and b) an SVG (also XML) file. The input text file (input.txt) contains the description of a number of produce distribution centers and storage centers around the country. Each line describes either a single distribution center (dcenter) or a storage center, each with a number of p...

Is it possible to define a variable in expression in C++?

I have this insane homework where I have to create an expression to validate date with respect to Julian and Gregorian calendar and many other things ... The problem is that it must be all in one expression, so I can't use any ; Are there any options of defining variable in expression? Something like d < 31 && (bool leapyear = y % 4 =...

Decent shared_ptr implementation that does not require a massive library?

I am taking a C++ programming class right now on GIS Programming. I am really starting to get alot of headaches from dealing with proper memory management. Considering at any time there is often 8-10 classes each holding a pointer to a 3D matrix or something else very large. Now our class already raised the issue of the prof allowing us ...

Is there a way to store part of a 16 bit value in an 8 bit variable in Assembly?

I created one variable that stores a 16 bit variable, and I'm tring to store the upper half in an 8 bit variable. How do I do this? EDIT: its for the IA-32, and I don't think i can use registers EDIT2: I am allowed to use registers. ...

My password challenge problem

We are challenged to write a program that prompts the user to enter a password. The right password is " I Love Java programming " And it should be that the password has a single space before and after just like what I've written. Now, there is a condition, that if a user enters more than 2 or more spaces before or after the right passwor...

Picking info using junction table(SQL SERVER 2005) [ SET BASED]

I have 3 tables 1) tblPurchaser having 2 columns: PurchaserId PurchaserName 1 A1 2 A2 3 A3 2) tblCar having 2 columns: CarId Carname 11 C1 12 C2 13 C3 14 C4 And the last is a junction table tblInformation where the information about those persons are given who has purchas...

How to handle mouse event in C#

Hi, I'm new to C#. Please help me with this: I want to click inside a square and then, an "X" should appear. How to implement this is C#. Please help. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; na...

Declaring Unknown Type Variable in Python?

I have a situation in Python(cough, homework) where I need to multiply EACH ELEMENT in a given list of objects a specified number of times and return the output of the elements. The problem is that the sample inputs given are of different types. For example, one case may input a list of strings whose elements I need to multiply while t...

Non Blocking Server in Python

Hi, Can someone please tell how to write a Non-Blocking server code using the socket library alone.Thanks ...

CRC32 Collision

I am trying to find a collision between two messages that will lead to the same CRC hash. Considering I am using CRC32, is there any way I can shorten the list of possible messages I have to try when doing a brute force attack? Any links to websites with hints on this will be helpful. I already have a brute force algorithm that will do...

My problem is how do i make this work

import java.util.Scanner; public class Fraction { private int numerator; private int denominator; private int product; private int sum; public Fraction(int num, int denom) { this.numerator=num; this.denominator=denom; if (this.denominator == 0){ System.out.println("can not divide by zero"); }// end if }// end fraction ...

How long dose it take to analysis, design and program a CMS using ASP.NET ?

Hi, I'm a student and I have to choose a final year project for my diploma in computer programming. I intend to choose developing a Web Content Management System using asp.net with VB.net 2008 but I'm not sure about how long it takes to program such system. Is 4 months enough for developing such system? This 4 months is the duration of ...