int main()
{
int retnum = (1000 * 365 * 24 * 60 * 60)
return(retnum)
}
But I am working with arrays so I want to know how to do it like this..
1 2 3 4 5 6 7 8 9 10 11 12
int main()
{
int n=0;
int retnum=0;
char Millenium[1000][365][24][60][60];
for (n;n<sizeof(Millenium);n++)
{
retnum += n;
}
return(retnum);
}
Any help here? I'm just trying to learn arrays, I know there are simpler ways of getting the seconds in a millenium, and believe me I really dont care how many there are. Another question I have, is the above code using the array coded right? It won't compile because it says the array is too large. I'm using Dev-C++ because I'm a cheapo ;)
Actually, 1000*365.2425*24*60*60, give or take a few minutes.
And your array would use 29.37 GB.
EDIT: Your loop is not properly coded. It should be retnum++. What you're doing right now is 0+1+2+3+...+n-1 (which, by the way, is the same as ((n-1)^2+n-1)/2).
Also, you could just do retnum=sizeof(Millenium).
// arrays example
#include <iostream>
usingnamespace std;
int billy [] = {16, 2, 77, 40, 12071};
int n, result=0;
int main ()
{
for ( n=0 ; n<5 ; n++ )
{
result += billy[n];
}
cout << result;
return 0;
}
Thats where I got the idea but im tryin to do the same effect with a multidimensional array.
Thanks, but the whole point of doing this is to figure out how to get that process done with a MULTIDIMENSIONAL array, getting the numbers not important to me. That way you had it set up was a single dimensional array with an array size of 6. So it looks like this..
[ 1000] [365.2425] [24] [60] [60] [0]
I'm looking for a MUTLIDIMENSIONAL array, so just random numbers if I declared an array by typing int mdarray[2][5] it would look like this..
1 2 3 4 5
[x] [x]
[x] [x]
[x] [x]
[x] [x]
[x] [x]
Do you understand what I'm trying to do? You can use whatever example you want, I guess I'm just trying to see when a multidimensional array would be useful and how to go about initalizing and using it in a loop.
If you want to practice matrices, try calculating a Pascal's triangle (http://en.wikipedia.org/wiki/Pascal%27s_triangle ): 1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
If you want to make it harder, do it memory efficient.