mrnutty 761 Senior Poster

Unfortunately, I don't have one. Good luck with your project, sounds interesting.

mrnutty 761 Senior Poster

Well yea. If the user moves the stick from initial position to end position in a fast time, then you would expect the mouse to move in a fast time as well, right? Its like the mac, touch pad; touch the pad at one position, and quickly move it to a destination , then the mouse would have to quickly move to the destination as well right? And if the user slowly moves the the stick then the mouse should move slow as well right?

mrnutty 761 Senior Poster

ok stuff like this might be a little test and trial. But how about saving three states, previous mouse position, post mouse position, and time interval of movement. This way you can derive the rate at which the user locks the stick in a position. Then use that information to transform it into mouse speed.
When your mapping it into the screen, are you using windows for manipulating the mouse or are you using other libraries? How about having a matrix that transforms logical position into pixel position( ex. (0,0) map to pixel (x0,y0) and (1,1) map to pixel(x1,y1) ) but you need to take into account the viewing perspective to differentiate the length between the amount of pixel from x = 0 to x = 1( assuming x is horizontal axis). This is what essentially opengl does.
And there might be libraries out there that takes care of this for you already so check that out as well.

mrnutty 761 Senior Poster

It would make more sense if you move it relative. Why would you want to move it absolute?

mrnutty 761 Senior Poster

>>how to rand between three integer num1 num2 num 3

You say in between the three integers. That means one of the numbers, either num1, num2 or num3 has to be a min or the max. Which means the last one has to fall in between. Thus this implies that you want a number in the range of , [ min(num1,num2,num3) to max(num1,num2,num3) ]; So a general formula is rand() % (max - min ) + min , or min + (max-min) * (rand()/(float(RAND_MAX+1))

mrnutty 761 Senior Poster

Post the code, and Narue, I'll bet that he uses region as 0 in one of his calls.

mrnutty 761 Senior Poster

Need more code. What type of exception? Is region a valid index?

mrnutty 761 Senior Poster

Another thing I must say is that because of programming and CSE in general, I have made a lot of new friends with varying personalities. Heck, my last girlfriend I meet was from a tutoring center for CSE. So I guess before programming, I had few friends, but after programming, don't know whether it was college or what but it definitely changed me for the better.

mrnutty 761 Senior Poster

Not quite. Assume you have this :

int numbers[5] = {1,2,3,4,5};

and now you want to print all values in the array.

Here are some hints. Generally you would want to use a for-loop when you know how many elements you want to iterate over. Google for loops.

To access an element in the array you can use the subscript operators like so

numbers[0]; //the first element
numbers[1]; //the second element
//...and so on

now all you need to do is combine what I said above into one. Give it another try.

mrnutty 761 Senior Poster

put SDL_Quit(); inside your CleanUp() function.

mrnutty 761 Senior Poster

Yes, I would assume gamedev uses external trusted libraries that has debugged code written and tested already instead of rolling their own. You could try to make one for your learning purposes, the easiest one being .bmp, but its up to you.

mrnutty 761 Senior Poster

It has made me more creative.

Thats very true. I started to think more logically in my everyday life. I realize that using rational thinking is the proper way of life, but of course there are some lines to draw rational thinking versus beliefs.

Hani1991 commented: Do you know that my belief is completely rational? :) +0
mrnutty 761 Senior Poster

Read this article. Although openGL isn't as popular as it use to be. It doesn't make it less powerful than directX. They are both capable of doing the same thing. The only difference is the popularity.

mrnutty 761 Senior Poster

lmao, I still have my life. I straighten out my priorities.

Before programming:
- Eat
- Poop
- Sleep
- Hangout
- repeat...
After programming:
- Eat
- Poop
- Program
- repeat

mrnutty 761 Senior Poster

Look into devIL. Generally, for these things you would want to use an external library.

mrnutty 761 Senior Poster

Whats the point of car? I mean given the material we should be able to create one right?

mrnutty 761 Senior Poster

Some hints :

const char minLetter = 'A';
const char maxLetter = 'Z';
char randomChar = char( minLetter + rand() % (maxLetter - minLetter + 1));//returns a random character from [minLetter,maxLetter]
const int minInt = 0;
const int maxInt = 9;
int randomDigit = minInt + rand() % (maxInt - minInt + 1); // returns a random number from [minInt,maxInt]
mrnutty 761 Senior Poster

First of all, if(x==MINVAL) makes no sense, I think you meant to write if(x < MINVAL) .

Second, I'm pretty certain that you would be better off using a Tailor series expansion. All you should need is a Taylor series expansion around 0 degrees for both the sine and cosine, which is valid (within you desired precision) on an interval from -45 degree to 45 degrees (i.e. -Pi/4 to Pi/4). With simple trig. identities, you should be able to use those two expansions to calculate a sine, cosine or tangent of any angle. For example, for the sine of an angle of 80 degrees, you can compute the cosine of -10 degrees (which is in the Taylor series' range for the cosine), and similarly for other ranges of values.

Third, you should also remember that branchings (e.g. conditional statements) are surprisingly expensive and slow, you should reduce those to a minimum. Also, mark your free-functions with the keyword "inline" to allow the compiler to inline if it leads to faster code.

Finally, if you are using or can use C++0x, you should mark those functions with constexpr keyword to allow compile-time computation of the values whenever possible.

I would suspect using trig function be just as fast if not faster than taylor expansion.

@OP: Unless you are in a really limited environment, there is no need for all this complication. You should just use a simple one liner function call.

mrnutty 761 Senior Poster

If there is a match, then all you have to do is add the coefficients, else if there is not a match, then
you will needed to create a slot for the new term. Now where should the slot go? You need to make sure that the list is in order though.

mrnutty 761 Senior Poster

Not cool! Negetaive for telling the truth! I have nothings against OpenGL but the windows is REALLY trying to kill it. Plus I like to use DirectX because it got DiretInput and sound and other stuff.

Prove that opengl is dying and I'll offset the negative rep.

mrnutty 761 Senior Poster

Maybe an example would help :

Suppose this is your current polynomial : [tex] 4x^3 + 2x^2 + x + 3 [/tex]
and you want to add the term [tex] 5x^2 [/tex].

Then you look at you list of terms, and see if there is a term with an exponent equal to 2, and looking at it we see that there is a term with its coefficient equal to 2, that is this term [tex]2x^2[/tex]. So we just add it, [tex]2x^2 + 5x^2[/tex] = [tex] 7x^2[/tex], and so your new polynomial will be [tex] 4x^3 + 7x^2 + x + 3 [/tex]

Now what happens if we want to add [tex] 2x^6[/tex] ? What should u do?

mrnutty 761 Senior Poster

Just read the definition of Big-Theta and apply from that. That question is basically asking you to know what the definition means.

mrnutty 761 Senior Poster

Look into opengl

mrnutty 761 Senior Poster

You need to define it as a function :

void send(int *to,int *from, int count)
{
         {
                 register n=(count+7)/8;
                 switch(count%8){
                 case 0: do{     *to++ = *from++;
                 case 7:         *to++ = *from++;
                 case 6:         *to++ = *from++;
                 case 5:         *to++ = *from++;
                 case 4:         *to++ = *from++;
                 case 3:         *to++ = *from++;
                 case 2:         *to++ = *from++;
                 case 1:         *to++ = *from++;
                         }while(--n>0);
                 }
         }
}
mrnutty 761 Senior Poster

prepend void before send(...), thus making send a function, because the compiler is thinking its a constructor of some sort.

mrnutty 761 Senior Poster

- I have started to grow grey hair after I started programming
- I have started to have notorious thoughts about my computer after I started programming.
- I have started to think like a semi-computer in my daily life

susheelsundar commented: lolololololol +0
mrnutty 761 Senior Poster

Try capital 'A' instead of lowercased 'a', in class Savings : public Account{...}

mrnutty 761 Senior Poster

Seriously, I don't get what the big deal is? They are just regular people like us, but somehow brainwashed the masses into thinking they are above us.

mrnutty 761 Senior Poster

Start thinking about the things you use to do before you ever knew about programming and now think about how you changed that as a result of programming? What was it?

As an example, I always use to start numbering from 1, but after taking my first programming course and then on, I now start my numbering from 0.

Care to share some of your thoughts?

mrnutty 761 Senior Poster

The above code is garbage and wont work for every compiler. Its trying to point to the address 0xE6EB54. Don't bother wasting your time with these nonsensical code.

mrnutty 761 Senior Poster

You should be using std::vector and std::string. Thus assuming that, you can do the following :

bool found = std::find( vectorOfStrings.begin(),vectorOfString.end(),stringToFind) != vectorOfString.end();
mrnutty 761 Senior Poster

make it like so :

template<typename T> void Stack<T>::push(const T& val);

notice the constant.

mrnutty 761 Senior Poster

Rule of thumb:

When using pointers, if possible, use the arrow operator (->)
When not using pointers, use the dot operator ( . )

mrnutty 761 Senior Poster

Man, I just passed by teen years. I'm 20 currently. Times flies by so fast. I started like 2-3 years ago. It became an obsession initially, then started to die down a little, because I have way too much work to do,in and out of school. As an advice, I suggest you to not worry about learning many languages as some might, and first consider 'mastering' one language. Then focus on designing good solutions, which in part is creating good algorithms and good structures. One way you can do this, is to go into graphics programming. This is not only really interesting, but also very thought provoking and give you an excellent chance to practice. Recently, in my interview, the interviewer was very impressed that I did game programming ( because they knew how hard it is ). Good luck with your future.

mrnutty 761 Senior Poster

Suggestion is to use std::string and std::sort. Its just a few liner :

#include <iostream>
#include <algorithm>
using namespace std;

int main(){
 std::string input;
 cin >> input; //get input
 std::sort(input.begin(),input.end()); //sort it
 cout << input << endl; //print it
 //or access each element like so 
 /*
     for(int i = 0; i < input.size(); ++i){ 
        cout << str[i] << " ";
     }
 */
}
naseerhaider commented: very helpfull +1
mrnutty 761 Senior Poster

You need proper includes.

#include <iostream>
using namespace std;

int main(){
 int x = 0; //initialize variables
 int y = 0; //initialize variables
 int z = x * y;  //calculate z
 cout << "Z = " << z << endl; //print out the variable 'z'
 
 return 0;
}
mrnutty 761 Senior Poster

Just curious why do you want this information?

mrnutty 761 Senior Poster

Its just a warning, goto the last line of the file and press enter.

mrnutty 761 Senior Poster

Given a very large large number( for example one with 1024 digits ), find all of its factors in polynomial time.

mrnutty 761 Senior Poster

references are more civilized than pointers only
because it looks easy to read, but it have all the
dangours that are associated with the pointers.

Not quite. You can assign a null to a pointer but not to a reference.

mrnutty 761 Senior Poster

When you create an array class, if you overload the [] operator, then you need to return by reference and return by const reference. So in some situation, it is necessary.

mrnutty 761 Senior Poster

He told you why it doesn't compile. The vector contains ints. ints has no member functions. So when you call vector.begin() it returns an iterator that points to a list of ints. And when you use the arrow operator on the iterator, it deferences the iterator, thus 'returning' ints. And so when you call the size() function on the ints, its a compile error because ints has no member function call size() or any other functions for that matter.

mrnutty 761 Senior Poster

You should provide default initialization for the Point class as so :

class Point{
 double x_,y_;
public:
 Point( double x  = 0.0 , double y = 0.0) 
  : x_(x) , y_(y) //use initialization list to initialize variables
  {}
};

the problem with your code what that there was no default constructor that take nothing as parameter.

mrnutty 761 Senior Poster

std::string.c_str() returns a const char*

mrnutty 761 Senior Poster

Why not use std::string? You can compare numbers and access the individual characters.

mrnutty 761 Senior Poster

Yea I agree with mike, unless there is a really good compelling reason to do this from scratch, you should reuse other libraries that have been debugged and tested for years.

mrnutty 761 Senior Poster

Is the equations always linear? Or polynomial? Assuming its linear equation then a good way to solve the problem is to first just add/subtract/multiply/divide all possible numbers in the equation, then all your left with is a equation of the form, AW + B = C where W is a variable, and A,B,C is some constant. Then you can go ahead and solve it. Thats a high level description.
How you add the numbers and ignore the variable is up to you. You can for example, first find the only variable in the equation, note it. Then proceed to compute the final values in the equations then solve it.

mrnutty 761 Senior Poster

Can you define what you mean by a critical path? Maybe give examples.

mrnutty 761 Senior Poster

Whats the quantum time? I'll assume its one. Try posting your answers here instead of attachments.

mrnutty 761 Senior Poster

>> The thing is you can never know.

I'm not sure about that. God could potentially come down and part the Red Sea or cure everybody or whatever right on CNN's cameras. Maybe even apply for James Randi's Million Dollar Challenge. Tell James he can film the whole thing from any angle he wants to prove it's not a trick. Then we'd all know for sure that it's true. Or we might all find out for sure that it's true after we die. What we'll never know for sure is that it's false if it is indeed false (i.e. He may exist all right, just never made the big splash).

Hence the atheist position that they don't have the burden of proof on this.

Thats the thing, we can never know. All of this could be false, even science. Thats why I say we never actually know if science can prove everything or not, because one can argue that we just don't have the technology to prove this right now, but who knows if such technology will ever exist?

Lately, my heads been all screwed up thinking about god. One minute he has my heart and others I start to question( sounds like my relationship with girlfriends ). At the end, I think we can only believe. But as a side note, now atheist position have the burden of proving that its not the case.