nezachem 616 Practically a Posting Shark

Sorry people, it is more than I can bear. We all agree that
1. The assignment is stupid
2. The code is ugly
3. OP doesn't have a clue
yet none of the above gives a reason to teach things you've not be asked for.

If you have nothing to say on the subject, it is perfectly OK to remain silent.

WaltP commented: Yes I CAN as 6 and 5 -- but I have to understand the problem to do that. -3
nezachem 616 Practically a Posting Shark

> Dev-C++

Missed that.

anonymous alias commented: why do you give me bad vote? :( you are one who made mistake!! I am giving helpful advice, look at the link!! :) +0
nezachem 616 Practically a Posting Shark

Something like this will work. Check your assembler docs for the syntactical specifics. What is important, you got the idea right.

nezachem 616 Practically a Posting Shark

It is a very nice disclaimer. The only problem (at least in US, and I suppose in UK as well) is that it has never been tried in a court of law. Until then nobody knows if it holds water.

nezachem 616 Practically a Posting Shark

Sin(x) = x - x^3/3! + x^5/5! + x^7/7! ...

Just wondering: are you intentionally trying to mislead OP?

nezachem 616 Practically a Posting Shark

"\bnf\b"

nezachem 616 Practically a Posting Shark

>> assuming I understand them

Yes, but instead of asking the user for the number N; N has to be
the sum from 2^0 -> 2^50. I though the instructions were clear enough, especially with the examples.

So the missing link in Narue's code is the summation?
Well then let's start with a few observations:
The sum itself is equal to 2^51 - 1. Assuming one decimal digit per byte a) we'd need 15 bytes or so to represent it; b) the Least Significant Digit (*) of 2th power is not zero hence subtraction of 1 is trivial; c) we just need a way to calculate a power of 2.
We can do it in a most straightforward way by means of multiply-by-two method:

int mul2(char * value, int len)
{
    int i, carry;
    for(i = 0, carry = 0; i < len; i++) {
        value[i] = 2 * value[i] + carry;
        if(value[i] >= 10) {
            value[i] -= 10;
            carry = 1;
        } else {
            carry = 0;
        }
    }
    if(carry == 1) {
        value[len] = 1;
        len += 1;
    }
    return len;
}

and call it as in

char data[20] = { 1 }; // "fifteen bytes or so"
    int i, len = 1;
    for(i = 0; i < exponent; i++) {
        len = mul2(data, len);
    }

This works, although for large exponents is highly inefficient. Which leads us to the next challenge:
Write a program which given an exponent N, designs an …

nezachem 616 Practically a Posting Shark

Watch for spaces around '='.

nezachem 616 Practically a Posting Shark

Hi, I'm trying to write a console program that will sort and find the median of numbers that are given in a text file. The text file can have ints or doubles.

The problem I'm having is outputting the median and the insertionSort functions. I think that they are failing because I did something wrong with either the vector or templates or both as it is my first time writing code using both of those.

Any insight is greatly appreciated.

template <typename T>
void median(const vector<T> & values) ;

template <typename T>
void insertionSort(ifstream& in_file, vector<T>& a_values);
...
	cout << "Sorted values are: " << insertionSort << endl;
	cout << "Median = " << median << endl;

Your assumption is wrong. Your insertionSort and median are functions. You never call them. You just output their respective addresses.