An infinite array would take up an infinite amount of memory and I suppose you don't have that?
Nick Evan
Not a Llama
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
Why not make an array of ints of a size of 84?
int possibilities[84];
possibilities[51] = 10;
If this is not what you meant, please explain clearer what your input and output should be.
Niek
Nick Evan
Not a Llama
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
here it is
When I read a post like yours, I always wonderwhy you reply. I mean, this thread hasn't had a reply in over 1.5 years, what gave you the idea that it needed your code? Which brings me to the code. Sorry to be harsh, but ...well...you know... it sucks. Fact is that it'll only run on something that starts with Turbo and that's just the tip of the iceberg. I'm glad to explain why, if you're interested?
Nick Evan
Not a Llama
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
>Sorry to harsh, but ...well...you know... it sucks.
It could always be worse. For example, he could be using a variable length array extension instead of new[] .
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
try to explain more please
Comments inred:
#include<iostream.h> // This header doesn't exist in standard C++. Change to <iostream>
main(){ // main is defined as int main, not void main.
int size; // not assigning a value here
cin>>size;
int *L;
L = new int [ size ];
// forgot to delete allocated memory
// return 0; is a good idea.
}
And you might want to ident your code.
And you replied to a two year old thread.
And you need to learn about using code-tags
Nick Evan
Not a Llama
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
int size; // not assigning a value here
cin>>size;
So? If the value is not usedbefore the cin , why do you need to set it to a value before that?
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
So? If the value is not used before the cin , why do you need to set it to a value before that?
I know, it's a matter of personal opinion. I always give variables an initial value, just to be sure. Here's a simple example why:
int i;
cin >> i;
cout << i;
this works just fine. But now I need to debug it and comment a line out:
int i;
//cin >> i;
cout << i; // uh-oh...
but if I had written:
<strong>int i = 0;</strong>
//cin >> i;
cout << i; // no problem, just display 0
So you're right, but I prefer to give variables a value when declaring them. Just a failsafe for myself :)
Nick Evan
Not a Llama
10,112 posts since Oct 2006
Reputation Points: 4,142
Solved Threads: 403
So? If the value is not used before the cin , why do you need to set it to a value before that?
I know, it's a matter of personal opinion.
Then state it as an opinion. What you stated was a requirement... :icon_wink:
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944