Archived

This topic is now archived and is closed to further replies.

This topic is 6388 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


#define MAX 33

struct xy
{
int nInts;
int *x;
} x[MAX];


........

int j;

for(int i=0;i for(j=0;j {
printf("%d\n",x.x[j]);
}


Visit our homepage: www.rarebyte.de.st

GA

Edited by - ga on June 16, 2000 1:53:54 PM

Edited by - ga on June 16, 2000 1:56:51 PM

Share this post


Link to post
Share on other sites
    
for (int j=0; j< 256; j++)
{
for (int i=j; i>5; i--)
{
for (int k=i-j; i+j < 65; k+=i)
{
cout << "If you tried to figure this out then may god have mercy on your soul" << endl;
}
}
}


now that is complicated


"Now go away or I shall taunt you a second time"
- Monty Python and the Holy Grail
themGames Productions

Share this post


Link to post
Share on other sites
I meant something useful like how to have people input something, the it is stored in an array. For example, if the typed in numbers it would find the average,times a number was repeated, etc.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster


int numbers[10];

for(int i=0; i<10; ++i)
{
cin >> numbers;
}




the ''int numbers[10]'' bit creates an array of 10 integers.
you access an element in the array by putting the number of the element you want into square brackets ''[]''... eg numbers[3] will give you the 4th integer in the array (since the indexes start at 0)

be careful though - C++ does no bounds checking, so ''numbers[54] = 3'' will compile fine, but will probalby crash when you run it.


simple as that.

Share this post


Link to post
Share on other sites
that last post was me but since i forgot to give my details, i cant edit it... so heres a brand new post


#include

int numbers[10];

for(int x=0; x<10; ++x)
{
cin >> numbers[x];
}

//small usage examples

numbers[0] = 2; //fine
numbers[53] = 3; //will compile ok, but will crash at run time

if(numbers[3] == 3)
cout << "the 4th element stores the number 3" << endl;


Edited by - POINT on June 16, 2000 5:22:18 PM

Edited by - POINT on June 16, 2000 5:23:24 PM

Share this post


Link to post
Share on other sites
I just made that post up as I went along.....
I had no intention for someone to figure it out.....
Did you really go through the trouble of seeing what happens ?
I guess you could just put it inside of a main loop, compile it and see what happens.


"Now go away or I shall taunt you a second time"
- Monty Python and the Holy Grail
themGames Productions

Share this post


Link to post
Share on other sites