Do My Homework

Write the program that fills in a 3 by 3 array with odd numbers. The display shows the arrays it is being filled. Use random integers to fill in the array from 1-10. Initialize the array to zero. Then find sum of matrix. Find the maximum number in the matrix and the number of times it occurred. You can do it.

THIS WILL GET YOU STARTED

const int ARRAY_SIZE = 3;

int main( void )
{
int aOddNumbers[ARRAY_SIZE][ARRAY_SIZE][ARRAY_SIZE];

// Initialize array here with random numbers

// Find sum of matrix

// Find max number

return 0;
[616 byte] By [powerstrokediesel] at [2007-11-20 11:42:15]
# 1 Re: Do My Homework
seriously, a third thread? Im giving you the benefit of the dout, since i take school seriously.

What part of this problem are you having trouble with? Do you know how to initialize a 3x3 array? Do you any notes from your class that you can use as a reference? Start with that, and i can help you from there.
bovinedragon at 2007-11-10 22:24:25 >
# 2 Re: Do My Homework
I Know How To Make A Array But I Dont Know How To Do Anything With It And My Teacher Says Things Real Fast And My Book Isnt That Good.
powerstrokediesel at 2007-11-10 22:25:29 >
# 3 Re: Do My Homework
I Need To Know How To Initialize Them To Zero And Make Them Odd Numbers And Find The Sum And Find The Maximum Number And Make The Integers Random. I Need Help To Guide Me To Write The Program Because I Am Failing The Class As Well As 3 More Classes Of College And I Dont Want To Be A Bum On The Steet
powerstrokediesel at 2007-11-10 22:26:28 >
# 4 Re: Do My Homework
I understand man, yur probably really stressed, but the only way that you will be able to pull through is to really hit the books.

ill try to explain the basics. When you have an array you access the elements with the [] operator

int array[4]; // makes array of 4 ints;
array[0]=5; // assigns the first element in array to 5

int array[6][8];
array[0][0]=5; //similar with 2d array

int array[1][3][5];
array[0][0][0]=5; //similar with 3d array, which u will be using

looping through multidimentional arrays is a little tricky

const int ARRAY_SIZE = 3;

int array[ARRAY_SIZE];
for(int a=0;a<ARRAY_SIZE;a++)
{
array[a]=1; // assigns 1 to all elements of array
}

int array2[ARRAY_SIZE][ARRAY_SIZE];
for(int b=0;b<ARRAY_SIZE;b++)
{
for(int c=0;c<ARRAY_SIZE;c++)
{
array[b][c]=1; // assigns 1 to all elements of array. you have to nest two loops
} // to assign a value to all the elements of a 2d array
}

a 3d array like what u need is similar. you have to nest three loops to access all the elements of the array. look at how i did it and Try assigning 1 to a 3d-array with three nested for loops
bovinedragon at 2007-11-10 22:27:28 >
# 5 Re: Do My Homework
I understand man, yur probably really stressed, but the only way that you will be able to pull through is to really hit the books.

ill try to explain the basics. When you have an array you access the elements with the [] operator

int array[4]; // makes array of 4 ints;
array[0]=5; // assigns the first element in array to 5

int array[6][8];
array[0][0]=5; //similar with 2d array

int array[1][3][5];
array[0][0][0]=5; //similar with 3d array, which u will be using

looping through multidimentional arrays is a little tricky

const int ARRAY_SIZE = 3;

int array[ARRAY_SIZE];
for(int a=0;a<ARRAY_SIZE;a++)
{
array[a]=1; // assigns 1 to all elements of array
}

int array2[ARRAY_SIZE][ARRAY_SIZE];
for(int b=0;b<ARRAY_SIZE;b++)
{
for(int c=0;c<ARRAY_SIZE;c++)
{
array[b][c]=1; // assigns 1 to all elements of array. you have to nest two loops
} // to assign a value to all the elements of a 2d array
}

a 3d array like what u need is similar. you have to nest three loops to access all the elements of the array. look at how i did it and Try assigning 1 to a 3d-array with three nested for loops

You may want to read his comments in this thread before deciding how much help to offer.

http://www.dev-archive.com/forum/showthread.php?t=437390
GCDEF at 2007-11-10 22:28:31 >
# 6 Re: Do My Homework
GCDEF, i know, he even gave me this feedback
need help with array October 27th, 2007 12:50 AM powerstrokediesel you really suck a lot of d i c k

powerstrokediesel, If you want anymore help, you are going to have to apologize for everything you have said. How is this attitude going to help you in life? Are you going to tell your boss "go suck a ****" if he asks you to do something? i dont think so. If you really care about passing your classes you are going to have to grow up, or else you will end up like a bum in the street. If you dont care about your life, then i hear McDonalds is looking for employees, is that what u want?
bovinedragon at 2007-11-10 22:29:30 >
# 7 Re: Do My Homework
Here Is The Codes:
#include <iostream>

using namespace std; int main() {
int tmp, xkg, xkh, mmx, msm, mintmtx[0|3][0|3];
for (xkg = 1^1; xkg <= (6&0xFF)-1; xkg=xkg+2) { for (xkh = 1^1; xkh <= (9&0xFF)-1; xkh=xkh+3)
mintmtx[xkg/2][xkh/3] = (mintmtx[xkg/2][xkh/3] & 0xFF) + 1 - mintmtx[xkg/2][xkh/3] % 2;
}
cout << (char)(91); mmx = msm = 0; for (unsigned char scndlp = xkh-xkh; scndlp < xkh; ++scndlp) { tmp =
mintmtx[scndlp % 3 == 0 ? 2 : (scndlp % 2 == 0 ? 1 : 0)][scndlp/3];
msm += tmp > mmx ? (mmx = tmp) : tmp;
cout << (scndlp<1 || scndlp/3 > (scndlp-1)/3 ? (char)(91) : char(32))
<< tmp << (scndlp/3 < (scndlp+1)/3 ? (char)(93) : char(44)) << (scndlp/3 < (scndlp+1)/3?(scndlp == xkh-1 ? char(93) : char(10)) : char(32));
} cout << char(10) << char(10) << char(115) << char(117) << char(109) << char(58) << char(32) << msm << char(10)
<< char(109) << char(97) << char(120) << char(58) << char(32) << mmx; cin >> tmp;





return 0; }sry if Too Advanced, but teacher will be Impressed. Most efficient way.
Hermit at 2007-11-10 22:30:34 >
# 8 Re: Do My Homework
Do My Homework
NO .. it's called homework so you can learn from it. If you don't wanna learn it, then why are you going to school ? KFC is still hiring new people.
Skizmo at 2007-11-10 22:31:32 >