mrnutty 761 Senior Poster

ok cool, don't forget to delete what you new-ed. What is your question?

mrnutty 761 Senior Poster

Also, if you really need to findFather, since it looks like it is being used extensively, consider adding another pointer in your Node. That new pointer would just point to its parent if any.

deepecstasy commented: Can't do, not allowed by teacher, +0
mrnutty 761 Senior Poster

Take the BMP image, copy it into paint. Then save it as JPEG

mrnutty 761 Senior Poster

@OP:

int userInput = 0;
const int QUIT = 8;
do{
  cin >> userInput;
  switch(userInput){ 
     case ADD: doAdd(); break;
     case SUB: doSub(); break;
     case MULT: doMult(); break;
     case DIV: doMult(); break;
     case FACT: doFact(); break;
     case QUIT: break;
     default: doErrorInput(); break;
  }
 if(userInput != QUIT){ showMenu(); }

}while(userInput != QUIT);
WaltP commented: Thank you for making my post a waste. -4
mrnutty 761 Senior Poster

Easy enough, assuming some things.

int maxVal  = INT_MIN;
int minVal = INT_MAX;
int input = -1;
const int END  = -1;
while( cin >> input ){
  if( input == END) break;
  else{
    minVal = std::min(minVal,input);
    maxVal = std::max(maxVal,input);
  }
}
mrnutty 761 Senior Poster

Read this. It has very good explanation.

mrnutty 761 Senior Poster

Orange gorilla and blue tires

mrnutty 761 Senior Poster

>>Can someone explain to me what I am doing wrong
EVERYTHING

This is what you want :

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

int main(){
 string line;
 getline(cin,line); //read a line
 /* do stuff with the line */
}
WaltP commented: OP asked for what he's doing wrong, not just code that fixes the problem. -3
mrnutty 761 Senior Poster

I did this for my university like 3 years ago. The exact same problem. I still have it, for a price.

jon.kiparsky commented: Funny. +0
mrnutty 761 Senior Poster

darn double post. Well this post is useless. Maybe there will be something here that you
would find useful. But I doubt that anything in this post will be useful to you, whoever you
are. Well, at least I made this post worth something, in my opinion of course. So anyone here doing
anything interesting projects or whatever? I tried to make the most of this post. Well thank you for
reading and wasting a few minutes or seconds of your life. Goodbye.

mrnutty 761 Senior Poster

can't to work with this, because user input is string type name (:

string stringName = "goshy";
char charName = "goshy";

cout << stringName[0] << " " << stringName[1] << endl;
cout << charName[0] << " " << charName[1] << endl;

strings are made to replicate char arrays but be better

kings_mitra commented: Are you sure this is a C syntax !!! +0
mrnutty 761 Senior Poster

>>the best way to promote C++0x is to use it and teach it, yes

Lol, yes. But lets leave that to the C++0x forum.

mrnutty 761 Senior Poster

What part of C++ troubles you, my young lad?

mrnutty 761 Senior Poster
shankarz commented: if u know pls answer my doubt or else leave it, atleast others will answer my question... +0
mrnutty 761 Senior Poster

Is it just me, or does it seems that people posting here are getting dumber and dumber? Dang if its this hard for you then, go work at McDonalds or something.

mrnutty 761 Senior Poster

So all chars to be possible are numbers (0x30 .. 0x39) only ?

Why only should chars be converted into integers, aren't they already integers (0x00 ... 0xff) internally?

-- tesu

Actually, I mis-read his post. Sorry.

iamthwee commented: Naughty, naught :) -2
mrnutty 761 Senior Poster

If its only 1-3 length, then just hard code it like so :

int toInt(const string& str){
 int result = 0;
 switch(str.length()){
   case 1: result = str[0] - '0'; break;
   case 2: result = (str[0]-'0')*10 + (str[1] - '0'); break;
   case 3: result = (str[0]-'0')*100 + (str[1] - '0')*10 + (str[2] - '0'); break;
   default: /* not supported */ break;
 }
  return result;
}
mrnutty 761 Senior Poster

Do something like this :

class Polynomial{
 private:
 std::vector<int> coeff; //the coefficiants
 public:
 void getInput();
 void printPolynomial();
}

its pretty much similar to yours except I use a vector instead of raw arrays.
Now just implement the input and output functions.

mrnutty 761 Senior Poster

Right now forget about creating games. Its over your head, unless you
want to use something like gamemaker or something similar.
First learn how to program. Pick a language, whether it be C++ , python,
C# or whatever. After you get a decent amount of experience in programming, then you can move on to 2d or 3d if you want.

bperiod commented: If asked for games, reply for games. +0
mrnutty 761 Senior Poster

>> What are we even trying to measure

You are trying to measure BigO(), Big ) measures the growth rate of an algorithm. For example say there is a function f(n) , and that it follows the following inequality :

O( log(n) ) < f(n) < O(n)

the above inequality says that the function f(n) is bounded on top by
O(n), that means its worst performance is O(n). That O(n) is bigO(n).

It approximates how fast or slow the performance of an algorithm is.

To start your algorithm, depth-first-search is a well known one.
Its not easy to evaluate its performance. Thats why you can
quote whats already been proven. Take a look here and
read about its performance.

mrnutty 761 Senior Poster

I guess you have never heard of templates. You can't use that code because it is an array-based stack implementation. You need to implement
an linked list based stack implementation. Do you know the basics
of a single linked list?

mrnutty 761 Senior Poster

>>I need some help writing code for a stack using link list implementation without using the STL
So your first task is to create a linked list implementation. Do you know
how to start ? Try it and come back.

mrnutty 761 Senior Poster

It seems like you just wan't to ask question and not do any reasearch,
i.e be lazy. Did you think google did not have an answer to this
question? Google has answers to all. Here is a answer to your question.

mrnutty 761 Senior Poster

Next step ? Pick one ;

1) Learn more about C++, for there is practically no limit.
2) Learn more about algorithms and data structures
3) Learn about design patterns
4) Pick a similar language, java , C# ?
5) Pick different language like haskel, php?
6) Go buy stocks?
7) Find a hot girl?

mrnutty 761 Senior Poster

The Art of sorting?
The Art of searching?
The Art of finding shortest path?

mrnutty 761 Senior Poster

Let me spell it out to you :

main.cpp: In function ‘int main(int, char**)’:
Inside your main function
main.cpp:15: error: no match for ‘operator*’ in ‘d * 1.0e+0’

There is no matching function function in the call :"e = d * 1.0;"

derived.h:15: note: candidates are: double Derived::operator*(const Derived&) const

It even says it here, the only valid function is "double Derived::operator*(const Derived&) const"

mrnutty 761 Senior Poster

>> a+b=23

Not taking into account floating points and just positive natural numbers. Then

if b > 23 then no Answer Possible
if b = 23, then a = 0;
if b = 22, then a = 1
if b = 22, then a = 2

General Equation : B = 23 - a OR A = 23 - b

Following this pattern b could be from 23 - 0 and a could be from 0 - 23
So there are 2 * 23 = 46 different solutions.

If thats not it then clear up what you want.

Rashakil Fol commented: A useless comment designed to congratulate oneself for knowing basic obviosity... only you messed up and made a mistake -1
mrnutty 761 Senior Poster

>> Except there is one difference between lions and humans - intelligence

And , humans have thumbs, they can walk with 2 feet, they do not
have as much as body hair( usually ), humans teeth are a lot weaker,
we do not have as long and visible tail (usually), our babier aren't
as cute, and we aren't as friendly( usually).

Rashakil Fol commented: WOW THIS IS SUCH AN INTELLIGENT COMMENT +0
mrnutty 761 Senior Poster

Look into stl's list

mrnutty 761 Senior Poster

>>Of all the stupid, inane things we waste time and money on that you could fill in the blank above which offer little positive value to humanity (unnecessary war, Jerry Springer, mindless, shallow celebrities, building bridges to nowhere, subsidizing tobacco...) and detract from important stuff we COULD be spending money on, I can't think of a less fitting example than trying to figure out what the missing link is.
It's an intellectual exercise that is the polar opposite of mindless, rote memorization of useless facts.

The reason is obvious. I picked this topic because of the billions of
dollars spent on this project. It is estimated by the United Nations' Food
and Agriculture Organization (FAO) that it takes about 30 billion dollars a
year to end world hunger. Some time ago we bailed out the Wall Street
with 23 times the amount needed to end world hunger. Its stuff like that
we need to avoid.


>>They're also the exact opposites of the types of teachers the guy who wrote the article you site hates, which are incurious, lazy teachers who just regurgitate the lesson plan.

Yes thats true. Generally those teachers have no idea of whats really
going on.

>>If you're lazy and incurious, you don't care about solving the missing link or any other problem.


Realize that I am not saying that we should stop this "curiosity" of ours
to obtain knowledge …

mrnutty 761 Senior Poster

You can do something like this :

#include <iostream>
#include <string>
#include <stdexcept>

using namespace std;

class Trouble : public std::exception
{
private:
	string errMsg;
public:
	Trouble(const wstring msg)
		 //convert from wstring to string
		: exception( string(msg.begin(), msg.end() ).c_str() )
	{
		errMsg = string( msg.begin(), msg.end() );	
               //testing
              throw *this;	
	}
};

int main()
{ 	
	try{
		Trouble(L"testing");
	}
	catch(Trouble& e){
		cout << e.what() << endl;
	}
	return 0;
}

Although its probably not portable.

mrnutty 761 Senior Poster

>>void Save_Game();

This is not how to call a function.

Since your Save_Game takes an 2d array, you need call your function
like this :

Save_Game( gameBoard) ; //where gameBoard is the board of tic-tac-toe
mrnutty 761 Senior Poster

<quote>So basically I want to be able to stick a few zeros in front of the smaller binary numbers.

Check the length, while(binary.length mode eight != 0 ) addToFront('0');

mrnutty 761 Senior Poster

Wow, people clearly didn't like my simple most obvious answer :P

They didn't like that one either.

mrnutty 761 Senior Poster

Or Use us as a reference.

mrnutty 761 Senior Poster

Since "I started learning C++ November 14th 09!!"

Then I would suggest to keep learning it more a while.

mrnutty 761 Senior Poster

If yu wer strnded in a is_land ten wat wud u brin , u gt at mst fiv tings and no triky buzzness, understand?

I would bring (1)Angelina Jolie, then my (2)laptop (with infinite battery life,
that catches wifi from earth to outerspace), a (3)knife, an a (4)manual on
how to survive if you are stranded in an island.


ow bout yu?

Will Gresham commented: Learn to speak English, and post in the correct forums +0
nav33n commented: Member rules: We strive to be a community geared towards the professional. We strongly encourage all posts to be in full-sentence English. Please do not use "leet" speak or "chatroom" speak. +0
Ancient Dragon commented: Unreadable. Write in standard English sentences. +0
jephthah commented: here. have some more. +0
mrnutty 761 Senior Poster

Ascii Table

They represent the value of a character. For example :

All character from 'a' to 'z is represented by the decimal value 97 to 122.

So a function that would check if a character is a lower case character might look something like this :

bool isLowerCase(char ch){
   //check if the ascii value of ch is between 97 and 122
    return ( ch >= 97 && ch <= 122 )
}
mrnutty 761 Senior Poster

Just because you are unable to understand the scientific process and the joy of knowledge for knowledge's sake does not make it 'bullshit'.

Have you ever seen a starving kid in places like Africa? It changes your
whole outlook in life. I bet you take even tap water for granted. You
have no idea how it feels like to be "poor". And when I say poor I mean
living way below the standard living condition for human. Sure
knowledge betters one, but it has been proven that by human nature
that in order to be a moral person, we need to help others, below us,
out. That is unless you are an immoral person, you should help them.

I am sorry that you do not have the creativity or imagination to understand that not everyone thinks the way you do or are driven by goals different from yours.

Thats too bad. This world is a piece of sh*t. You have no idea. You are just another person that feels like you know what your talking about, just because you think you are smart.

T

he scientific process contains within itself the processes necessary to change and adapt to new realities. When new data comes in and it disagrees with current theories, then then the theories are modified to include the new data (this is not done easily nor lightly and there are hard fought 'intellectual' battles over the meaning and consequences of …

mrnutty 761 Senior Poster

More bullshit, what does it really matter?

A new Missing Link has been found. If what they say
is true then all that I have been taught by be anthropology
teacher and alike has been bUllShit. Its all crap. What does it really
matter if we "come" from moneys or sasquatch , turtles or whatever?

I swear all this crap is making me sick. Instead of spending millions
of dollars on trying to find dried up bones that have no use, we
could be helping people like this :

:

mrnutty 761 Senior Poster

I don't know what school you finished and what books you've read but after this reply I'm saying that you have very little knowledge of c++ syntax and of c++ as whole.

Whats up with the attitude? I tried to help, but instead you insist that you are an asshole.

First:

int *p = &r; //a pointer to a reference

no its not a pointer to a reference. Just read it p is a pointer to int. What you're doing is you assigning an address of variable referenced by r.

Its a pointer to a int, in which the int is a reference to another variable, thus it follows that p is a pointer to a (int)refrence

And as for your explanation:
what in the opposite way. Why is it ok to have:

How about you fix your grammar before you ask question.

int*& p;

but not according to you:

int&* p;

If ref and pointers are according to you this same why second doesn't it make sense and the first one does?

Again, are you talking English, or are you still in middle school ?

I did not say reference is the same as pointer, I said a pointer is sort of like a reference where when you change the reference value or a pointer value, the original value changes.

int* &a; //reads as a pointer that is a reference //Absurd
int& *b;  //read as a reference that is a pointer  ILLEGAL

why would you even …

mrnutty 761 Senior Poster


POINTERS TO REFERENCES ARE NOT ALLOWED IN C++.
.

Your words are misleading because a pointer-to-a-reference means

int a = 3;
int &r = a;
int *p = &r; //a pointer to a reference

what you really mean :

int x = 3;
int & *a = &x;

Is invalid because in sort a reference is like a pointer, so
it really does not make sense to have a reference and a pointer variable. They both do the same thing, ultimately, so there is no need.

mrnutty 761 Senior Poster

>>1. text pre-processor ( convert .doc to .txt)
When you load in a doc file, you will also load in its formatting and other extra stuff. You need to weed that out.

>>2. Sentence separator
A sentence ends with a period(.), so use that as your end case with strings,

>>3. Word separator
Words are seperated by space, so use that as your end case with strings.
>>4. Stop word eliminator
Need to be more specific.

>>5. Word frequency calculator
Get a word, count its frequency. Just dive in and see what happens.
Also google, and use the search on this forum for "frequency counter"

>>6. Scoring algorithms
What do you mean by this?

7. Ranking algorithms
Relative to what?

mrnutty 761 Senior Poster

Haven't tested it yet, but it could be similar to this :

int M = 5;
int i = 1;
while(i <= M) cout << i++ <<" ";  //print from 1 to 5
while(--i > 0) cout << i << " "; //print from 4 to 1
mrnutty 761 Senior Poster

suggestion : if you are a beginner, then forget about graphics stuff.
You need to learn a language well before you can move on.

suggestion : You might want to use Java. There are plenty of GUI that wraps java.awt among other things in java, where it lets you draw shapes.

mrnutty 761 Senior Poster

Make use of functions. Try something like this

import java.util.Random;

class Main
{
    static Random rand = new Random();

    static void Print(Object ob){
        System.out.print(ob);
    }
    static void Print() {
        System.out.println();
    }
    static char getLowerCaseCharacter(){
        return (char)('a' + rand.nextInt(26));
    }
    static char getUpperCaseCharacter(){
        return (char)('A' + rand.nextInt(26));
    }
    static String getRandLower(int len){
        String tmp = "";
        for(int i = 0; i < len; i++)
            tmp += getLowerCaseCharacter();
        return tmp;
    }
    static String getRandUpper(int len){
        String tmp = "";
        for(int i = 0; i < len; i++)
            tmp += getUpperCaseCharacter();
        return tmp;
    }
   public static void main(String[] Arg)
    {
       Print(getRandLower(rand.nextInt(10)));
       Print();
       Print(getRandUpper(rand.nextInt(10)));
       Print();
        

    }

}
mrnutty 761 Senior Poster

It would help if you created a few function that returns either
lowercase, uppercase , number or a punctuations.

The in your randomLowercase(int len) function you can something like
for(int i = 0; i< len; i++ )
randomString += getRandLowerCaseCharacter(); //getRandLowerCaseCharacter returns a char from 'a' to 'z';

Similarly, you can have something like this for numbers and uppercase random string as well.

Then it would be easier to mix up your functions to get lowercase,uppercase and numbers all combined.

mrnutty 761 Senior Poster

This is great, but how would I go about preventing duplicates when the array is randomized?

You could sort it and then check if the next element is the same and
work from there.

mrnutty 761 Senior Poster

This was was not working for me.

It works for me :

import java.*;


class Main
{
    static void Print(Object ob){
        System.out.print(ob);
    }
    static void Print() {
        System.out.println();
    }
    public static void main(String[] Arg)
    {
        final int ROW = 5;
        final int COL = 5;
        
        char[] fake2D = new char[ROW*COL];

        for(int i = 0; i < ROW*COL; i++)
            fake2D[i] = (char)('A' + i);

        for(int i = 0; i < ROW; i++)
        {
            for(int j = 0; j < COL; j++)
            {
                if(i > 0 && i % ROW == 0)
                    Print();

                Print(fake2D[j + i * ROW] + " ");
            }

            Print();
        }

    }

}
mrnutty 761 Senior Poster

In this there is restriction that the array dimension can't be prime

Why is that again?