homework

missing subscript c++

right now c++ is giving me this error: error C2087 'color' missing subscript first time i get this and i dont know what to do >.< hope any1 can help me struct Color{ float r; float g; float b; }; Color color[][]; and im using it here for(int i=0;i<cubes;i++) { color[i][0].r = fRand();color[i][0].g=fRand(.5);color[i][...

Check if there are any repeated elements in an array recursively

I have to find recursively if there is any repeated element in an integer array v. The method must have the following signature: boolean hasRepeatedElements(int[] v) I can't see any way of doing that recursively without having to define another method or at least another overload to this method (one that takes for example the element...

descending heap sort

use heap sort to sort this in descending order and show the steps or explanation please below is the tree 79 33 57 8 25 48 below is the array 79 - 33 - 57 - 8 - 25 - 48 ok ascending is easy because the largest eleme...

Initialize a Variable Again.

That may sound a little confusing. Basically, I have a function CCard newCard() { /* Used to store the string variables intermittantly */ std::stringstream ssPIN, ssBN; int picker1, picker2; int pin, bankNum; /* Choose 5 random variables, store them in stream */ for( int loop = 0; loop < 5; ++loop ) { ...

Hi can anyone try how to solve the query for this table structure???

Employee table structure first_name varchar2(100) last_name varchar2(100) hire_date date show all the employee who hired on the day of the week on which highest number of employees were hired? ...

Count total number of digits from a given positive number without looping in C

How to count total number of digits from a given positive number without looping in C? ...

Question about permute-by-sorting

In the book "Introduction to Algorithms", second edition, there is the following problem: Suppose we have some array: int a[] = {1,2,3,4} and some random priorities array: P = {36,3,97,19} and the goal is to permute the array a randomly using this priorities array. This is the pseudo code: PERMUTE-BY-SORTING (A) 1 n ← length[A] ...

grep a specific word and sum it

I want to grep an environment variable env | grep ABC_IJK[1,2] currenlty defined variables are like this ABC_IJK1=123 ABC_IJK1_XYZ=sn123:345 ABC_IJK2=999 ABC_IJK2_XYZ=sn321:999 I only want to get only this ABC_IJK1=123 ABC_IJK2=999 get number of connections sum them(not 123 + 999) and save in N1 (this one has 2 connection) ...

Encrypting a file in win API

hi I have to write a windows api code that encrypts a file by adding three to each character. so I wrote this now its not doing anything ... where i go wronge #include "stdafx.h" #include <windows.h> int _tmain(int argc, _TCHAR* argv[]) { HANDLE filein,fileout; filein=CreateFile (L"d:\\test.txt",GENERIC_READ,0,NUL...

How to draw a square on a video and track the object enclosed by the square ?

I am doing a Final Year Project to track an object(human) by drawing a square around a human in a video. I am doing this project in C#.NET. I asked in a forum about this and they said to use GDI+ and mouse handling (which I have no clue about). Do I have to do segmentation and then identify the region where the square was drawn ? split...

Finding an available network port on the machine

I'm trying to implement a simple FTP server (a variation of the EFTP protocol) in linux. When a client connects and sends the PASV command, the server should respond with a port number, so the client can connect to that port to transmit the file. How can the server choose a port number? Do I need to iterate through all the ports from 102...

comlen function in Java

in c or c++ the function comlen is defined such int comlen(char *p,char *q){ int i=0; while *p && (*p++==*q++) i++; return i; } Is this code equivalent of this function? int comlen(String s,String m){ int i=0; while (i<s.length() && s.charAt(i)==m.charAt(i)){ i++; } return i; } ...

Solve Physics exercise by brute force approach..

Being unable to reproduce a given result. (either because it's wrong or because I was doing something wrong) I was asking myself if it would be easy to just write a small program which takes all the constants and given number and permutes it with a possible operators (* / - + exp(..)) etc) until the result is found. Permutations of n di...

What is "Call By Name"?

Hi to everyone! I'm working in a homework, and the professor asked me to implement the evaluation strategy called "call by name" in scheme in a certain language that we developed and he gave us an example at http://www.scala-lang.org/node/138 in the scala language, but i don't understand in what consists the call by name evaluation stra...

Pointers in c/c++

#include <stdio.h> void main() { int p[]={0,1,2,3,4}; int *a[]={p,p+1,p+2,p+3,p+4}; printf("%u %u %u",a,*a,*(*a)); } What *(*a) will print(will it print 0 or it's address)? And if we make array p as static(static int p[]), output gets changed .Why? ...

Is this a good database design?

I am planning to make a railway reservation project... I am maintaining following tables: trainTable (trainId,trainName,trainFrom,trainTo,trainDate,trainNoOfBoogies)...PK(trainId) Boogie (trainId,boogieId,boogieName,boogieNoOfseats)...CompositeKey(trainId,boogieId)... Seats (trainId,boogieId,seatId,seatStatus,seatType...

How to get N random string from a {a1|a2|a3} format string?

Take this string as input: string s1="planets {Sun|Mercury|Venus|Earth|Mars|Jupiter|Saturn|Uranus|Neptune}{?|!|.}" string s2="some text {morning,night,evening} some text{?|!|.}" How would I choose randomly N from the set, then join them with comma. The set is defined between {} and options are separated with | pipe The order is mainta...

Saving object state on Java without using external memory

Good day. I know that in order to save object state in Java I should use serialization. But in every single topic about serialization states that I must save my object somewhere (disk, network). My problem is that I'm not allowed to do so. I need a way to save and recover object state without writing it on "external" memory. Maybe to sav...

Function derivatives

I have some function, int somefunction( //parameters here, let's say int x) { return something Let's say x*x+2*x+3 or does not matter } How do I find the derivative of this function? If I have int f(int x) { return sin(x); } after derivative it must return cos(x). ...

parallel sorting methods

in book algorithm in c++ by robert sedgewick there is such kind of problem how many parallel steps would be required to sort n records that are distributed on some k disks(let say k=1000 or any value ) and using some m processors the same m can be 100 or arbitrary number i have questions what we should do in such ...