How can I put a range of numbers in an array without typing in all the numbers. Like 0-24,25-49,50-74,75-100
I tried;
Is that a legal statement?Code:int x[] = {0-24,25-49,50-74,75-100};
any sugguestions?
Thanks
How can I put a range of numbers in an array without typing in all the numbers. Like 0-24,25-49,50-74,75-100
I tried;
Is that a legal statement?Code:int x[] = {0-24,25-49,50-74,75-100};
any sugguestions?
Thanks
>How can I put a range of numbers in an array without typing in all the numbers. Like 0-24,25-49,50-74,75-100
You don't. Try either building a vector at runtime or using paired numbers for the minimum and maximum of the range:
Code:int x[] = { 0, 24, 25, 49, 50, 74, 75, 100, };
The information given in this message is known to work on FreeBSD 4.8 STABLE.
*The above statement is false if I was too lazy to test it.*
Please take note that I am not a technical writer, nor do I care to become one.
If someone finds a mistake, gleaming error or typo, do me a favor...bite me.
Don't assume that I'm ever entirely serious or entirely joking.
Hey twm - chill on the sig man. Most people here are very cool and some of the best people you'll ever meet on a board. It's all good.
Usually you load an array from disk if you have a lot of numbers to put into it. Unfortunately there is no DATA like BASIC keyword that allows you to put data directly into the data segment and then retrieve it with a READ.
>Hey twm - chill on the sig man.
Joke...funny...laugh.
The information given in this message is known to work on FreeBSD 4.8 STABLE.
*The above statement is false if I was too lazy to test it.*
Please take note that I am not a technical writer, nor do I care to become one.
If someone finds a mistake, gleaming error or typo, do me a favor...bite me.
Don't assume that I'm ever entirely serious or entirely joking.
I'm not sure if this is what you wanted, but uhm, for loop?
Code:for(int i =0; i < max; ++i) array[i] = i;
FAQ
"The computer programmer is a creator of universes for which he alone is responsible. Universes of virtually unlimited complexity can be created in the form of computer programs." -- Joseph Weizenbaum.
"If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it." -- Richard Pattis.
You could use a 2d array, something like:
Note I didn't test this codeCode:int array[4][25] ; for (int x=0;x<4;x++) for(int y=0;y<25;y++) array[x][y] = y*(x+1);
Last edited by JaWiB; 10-31-2003 at 09:06 PM.
"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)
"Work hard and it might happen."
-XSquared