frogboy77 73 Posting Pro in Training

see this http://www.daniweb.com/forums/thread78223.html

particularly point 4.

frogboy77 73 Posting Pro in Training

a+=b;

is equivalent to

a=a+b;

frogboy77 73 Posting Pro in Training

Sorry Diophantine equations are beyond me. Perhaps you should try a math forum for more advice, then come here for help with the coding.

frogboy77 73 Posting Pro in Training

I think jonsca is correct, the answer seems too large to simply iterate through(be a little easy if so). I believe that there will be a clever mathematical shortcut.

It's not Euler but it's their kind of problem.

frogboy77 73 Posting Pro in Training

would unsigned long long int(instead of int) suffice?

frogboy77 73 Posting Pro in Training

it can be found on some very old nokia phones.

frogboy77 73 Posting Pro in Training

I presumed addition of the two without noticing they were of different size:$
Disregard my first post.

frogboy77 73 Posting Pro in Training

Am i correct in thinking you have been given an assignment in which you need to create a large array(and you are presumably using the same compiler as your teacher or whoever gave you this task) and you can't use pointers or vectors?

Then it seems like an unusual assignment.:confused:

frogboy77 73 Posting Pro in Training

can you use vectors?

frogboy77 73 Posting Pro in Training
int size = 85020;
int* array = new int[size];

//..utilize array

delete [] array; //release memory for later use
frogboy77 73 Posting Pro in Training

don't know of a clever way but using 2 arrays would work. read into array1 then into array2 then have a loop which adds the value in each part of array2 to each part of array1 then output array1.

frogboy77 73 Posting Pro in Training
frogboy77 73 Posting Pro in Training

answer immediately please

strange phrase. what seems to be an order followed by a plea????

frogboy77 73 Posting Pro in Training

You keep pencils in a beerstein? Germany and myself are appalled.

frogboy77 73 Posting Pro in Training

Static at approx 110 dB. Listening to the universe waiting for someone to say something.

frogboy77 73 Posting Pro in Training

Drill a hole on the bottom of each bucket and cover with the aforementioned tape. When u need to "flush" go outside and remove tape(spinning round will aid the process). Hope this helps.:)

frogboy77 73 Posting Pro in Training

ok

step 3.5 - If dying GOTO step 5
step 5 - Seek medical assistance.

This patch should clear things up.

p.s how do you spell dying(and not in the colour sense)?
am i right?

"dieing" that can't be right surely.

@ardav tape, 2 buckets and a willingness to stand bent over for a prolonged period.(if not tape string may work)

frogboy77 73 Posting Pro in Training

dropped it because it was harder than first class

is not entirely different from

'harder than I expected it to be'

neither is it a good reason.

frogboy77 73 Posting Pro in Training

Reading your post i feel the need to go out and buy some form of upper garment related to a sporting team. Can you help me?

frogboy77 73 Posting Pro in Training

:icon_rolleyes:

frogboy77 73 Posting Pro in Training

Give that you quit something because it wasn't easy, then it probably doesn't matter what you choose.

frogboy77 73 Posting Pro in Training

1,132,345,679 exactly at time of posting.

P.S my wife's computer just blew up so subtract 1.

frogboy77 73 Posting Pro in Training

Franka Potente.

frogboy77 73 Posting Pro in Training

Then you should mark the thread as solved.

frogboy77 73 Posting Pro in Training

cure

step 1 - Find pint glass.
step 2 - Fill with beer.
step 3 - Drink contents of glass.
step 4 - GOTO step 2.

this should fix it.

frogboy77 73 Posting Pro in Training

what do you mean "it is buyer uplift only." ?

come and get it.

frogboy77 73 Posting Pro in Training

Chuckie Egg, without doubt.

frogboy77 73 Posting Pro in Training

no problem you can have my old one but it is buyer uplift only.

EAnder commented: even a crappy computer from the 90s is decent enough to code on +0
frogboy77 73 Posting Pro in Training

You may recieve more help if you clearly state your problem. i.e what do you expect your program to do and what is it doing wrong.
P.S USE CODE TAGS.

frogboy77 73 Posting Pro in Training

i think you need to seed rand.

something like

srand(time(NULL));
frogboy77 73 Posting Pro in Training

In isprime can you not stop the search once the value in the vector is larger than the check value you send it?

frogboy77 73 Posting Pro in Training

a possible speed up would be to generate the primes in a seperate program and output them to a file, then read them into your program into a vector and check that. it would mean only generating them once.

frogboy77 73 Posting Pro in Training

thanks for the reply.
still very new at this so hope my questions don't seem too dumb.

frogboy77 73 Posting Pro in Training

thanks. so do i need to #include <ctime> to use clock()?

frogboy77 73 Posting Pro in Training

ok. any explanation why it seems to work?

frogboy77 73 Posting Pro in Training

very limited knowledge of this but this using ctime appears to give a rough time the code took to run.

double time=clock();
//program
cout<<clock()-time<<" ms"; or cout<<(clock()-time)/1000<<" seconds.";
frogboy77 73 Posting Pro in Training

This may work.

for(i=0;i<DetectedFaces.size();i++)
{
 temp.push_back(DetectFaces[i]);
}
frogboy77 73 Posting Pro in Training

With 2 nested loops(pure brute force) and a simple prime checker mine's works in about 1s but i'm too new to this to suggest where the slow down is.
Read the forum it's usually full of good tips.
As you have the generation of primes done you should take a look at the most recent problem(315). No maths but a nice programming exercise.

frogboy77 73 Posting Pro in Training

try google for isupper toupper etc.

never mind beat to the punch.

frogboy77 73 Posting Pro in Training

what about something like

for (int a = -999; a < 1000; a++)	
{				
      for (int b = 0; b < put size of array here; b++)		
      {				x = 0; 			
                                    while (isPrime(x*x+a*x+primes[b]))
                                    x++; 			
                                    if (x > max)			
                                    {				
                                    max = x;				
                                    max_co = a;				
                                    max_co_sec = primes[b];			
                                    }		
       }	
} 	
cout << max_co * max_co_sec << endl;
frogboy77 73 Posting Pro in Training

Am just a newb so this may be a stupid question, but i don't understand line 58

for (int b = -999; b < 1000; b = primes[index++])

why not

for (int b = -999; b < 1000; b++)

I've already done this but having looked at my code i'm not sure how(one off program so didn't comment on what i was doing) but both answers above are wrong although the second one is closer.

p.s what are your values for a and b?

frogboy77 73 Posting Pro in Training

I don't think next_permutation would work. It will give you the 24 permutations once you have generated the 4-digit number but it won't generate the numbers themselves.

frogboy77 73 Posting Pro in Training

as has been previously stated

int array[10]

contains 10 elements indexed from 0 to 9
if you attempt to read array[10] who knows what you will get.

SgtMe commented: as has previously been stated, therefore we do not need it again. +0
frogboy77 73 Posting Pro in Training
#includes <iostream>;

maybe

#include <iostream>

would work better.

frogboy77 73 Posting Pro in Training

@FutureWebDev

There are 210 ways to choose 4 from 10 but there are 24 permutations of each therefor 5040 is correct.

@MarounMaroun

How is your 2D-array (of size [1260][4]) going to hold 5040 combinations?

frogboy77 73 Posting Pro in Training

This is not overly difficult but as jonsca said have a go first.

frogboy77 73 Posting Pro in Training

What are the errors?

frogboy77 73 Posting Pro in Training

1. What is the problem?
2. Code tags code tags code tags.

frogboy77 73 Posting Pro in Training

@hayzam take some time and read the post from ravenous. there is plenty to be learned there.

frogboy77 73 Posting Pro in Training

Would a loop where you take mod 10 then divide by ten work?
i.e

while(num>0)
{//some code to add to the stack num%10
num/=10;}
thelamb commented: yupp +3