Ask your own question, for FREE!
Computer Science 15 Online
OpenStudy (anonymous):

how to transfer/array manipulation in 2dimensional array ?? please help..

OpenStudy (anonymous):

OpenStudy (anonymous):

OpenStudy (anonymous):

@Mertsj

OpenStudy (anonymous):

@satellite73

OpenStudy (anonymous):

please help guys

OpenStudy (anonymous):

@Ashleyisakitty

OpenStudy (anonymous):

@whpalmer4

OpenStudy (anonymous):

@lalaly

OpenStudy (anonymous):

@zepdrix

OpenStudy (anonymous):

help guys

OpenStudy (mertsj):

Sorry. I don't know this stuff.

OpenStudy (anonymous):

aww its ok THANK YOU parin @Mertsj

OpenStudy (anonymous):

@timo86m

OpenStudy (anonymous):

help guys..

OpenStudy (anonymous):

@wolfe8

OpenStudy (anonymous):

sorry

OpenStudy (anonymous):

awwwwwwwwwwwww

OpenStudy (wolfe8):

I learned this years ago for C. What do you use?

OpenStudy (anonymous):

#include<iostream> using namespace std; int main(){ int arr1[2][5]={{1,2,3,4,5}, {10,9,8,7,6}}; int arr2[5][2]={0}; cout << "\nAfter transfer... \n" << endl; //transfer the entry in array 1 to array 2. for(int i=0; i<5; i++){ arr2[i][0] = arr1[1][i]; arr2[i][1] = arr1[0][i]; } cout << "arr1" << endl; //print the first array for(int i=0; i<2; i++){ for(int j=0; j<5; j++){ cout << arr1[i][j] << " "; } cout << endl; } cout << endl; cout << "arr2" << endl; //print the second array for(int i=0; i<5; i++){ for(int j=0; j<2; j++){ cout << arr2[i][j] << " "; } cout << endl; } return 0;

OpenStudy (anonymous):

im using c++

OpenStudy (anonymous):

im not sure in my answer

OpenStudy (wolfe8):

Yeah it's kinda different than C by a bit. You might wanna Google this. There are a lot of programming forums.

OpenStudy (anonymous):

no.. there's no no answer in google

OpenStudy (anonymous):

Transfer the values from array1 to array2 such that array2 will have the following values: 1 2 3 4 5 6 7 8 9 10

OpenStudy (anonymous):

??

OpenStudy (anonymous):

i dont know what to put in the program to display like that .. :/

OpenStudy (anonymous):

please help...........

OpenStudy (anonymous):

@bbkzr31 hey its you ^_^

OpenStudy (anonymous):

lol

OpenStudy (anonymous):

hahaah sorry last time

OpenStudy (anonymous):

oh np, I had to go work on some math :P

OpenStudy (anonymous):

Your just wanting to start with one array and copy the contents of that array into another in C++?

OpenStudy (anonymous):

no i just need to change /add the TRANSFER statement

OpenStudy (anonymous):

to display this number 1 2 3 4 5 6 7 8 9 10 in 2Dimensional arrays

OpenStudy (anonymous):

and i only have 1 hour to answer that ;/ whahah

OpenStudy (anonymous):

and also after i answer the this 1 2 3 4 5 6 7 8 9 10 then after that i need to make a new Transfer statement and to diplay thiss (reversal) 10 9 8 7 6 5 4 3 2 1

OpenStudy (anonymous):

You posted some code earlier in the discussion is that working correctly?

OpenStudy (anonymous):

no.. i dont know if it is working correctly.. that only my wrong idea..

OpenStudy (anonymous):

so you aren't able to compile the code?

OpenStudy (anonymous):

and test it?

OpenStudy (anonymous):

no i dont have a compiler right now

OpenStudy (anonymous):

#include<iostream> using namespace std; int main(){ int arr1[2][5]={{1,2,3,4,5}, {10,9,8,7,6}}; int arr2[5][2]={0}; int arr3[5][2]={0}; int countOdd, countEven; //print the first array cout << "arr1" << endl; for(int i=0; i<2; i++){ for(int j=0; j<5; j++){ cout << arr1[i][j] << " "; } cout << endl; } cout << endl; cout << "arr2" << endl; //print the second array for(int i=0; i<5; i++){ for(int j=0; j<2; j++){ cout << arr2[i][j] << " "; } cout << endl; } cout << "\nAfter transfer... \n" << endl; //transfer the entry in array 1 to array 2. for(int i=0; i<5; i++){ arr2[i][0] = arr1[1][i]; arr2[i][1] = arr1[0][i]; } cout << "arr1" << endl; //print the first array for(int i=0; i<2; i++){ for(int j=0; j<5; j++){ cout << arr1[i][j] << " "; } cout << endl; } cout << endl; cout << "arr2" << endl; //print the second array for(int i=0; i<5; i++){ for(int j=0; j<2; j++){ cout << arr2[i][j] << " "; } cout << endl; } cout << "\nGet arr3 from arr2\n\n"; //do the transfer for arr3 for(int i=0; i<5; i++){ if(i%2 == 0){ arr3[countOdd][0] = arr2[i][1]; ++countOdd; } else{ arr3[countEven][1] = arr2[i][1]; ++countEven; } } for(int i=4; i>= 0; i--){ if(i%2 == 0){ arr3[countEven][1] = arr2[i][0]; ++countEven; } else{ arr3[countOdd][0] = arr2[i][0]; ++countOdd; } } for(int i=0; i<5; i++){ for(int j=0; j<2; j++){ cout << arr3[i][j] << " "; } cout << endl; } return 0; }

OpenStudy (anonymous):

Here is what you get when you run the code right now

OpenStudy (anonymous):

aww it is still wrong..

OpenStudy (anonymous):

i need to display it by [2][5]

OpenStudy (anonymous):

1 2 3 4 5 6 7 8 9 10

OpenStudy (anonymous):

is that what you want the second array to display?

OpenStudy (anonymous):

no

OpenStudy (anonymous):

oh, you want to change the formatting of the print statement?

OpenStudy (anonymous):

thats for the array 1

OpenStudy (anonymous):

array 2 is like this 10 9 8 7 6 5 4 3 2 1

OpenStudy (anonymous):

ok

OpenStudy (anonymous):

so for array 1 were gonna need, 1 2 3 4 5 6 7 8 9 10 So we need to print the first two elements of array1, then the second 2, then the last element and the first of array2, and so on. We want it to print out differently, correct?

OpenStudy (anonymous):

not understanding what you mean

OpenStudy (anonymous):

your right ...

OpenStudy (anonymous):

yes it should be in different statement..

OpenStudy (anonymous):

@bbkzr31 still there???

OpenStudy (anonymous):

//print the first array for(int j=0; j<5; j++) { cout << arr1[0][j] << " " << arr1[1][4-j] << endl; } I changed your print for loop to display like this.

OpenStudy (anonymous):

Is that correct? And how do you want the second array to be displayed Also is the second array being copied to the first one correctly yet?

OpenStudy (anonymous):

array 1 is already correct..

OpenStudy (anonymous):

after that the second array should display like this 1 2 3 4 5 6 7 8 9 10

OpenStudy (anonymous):

So array one is already displaying correctly, but array two is not copying or being displayed correctly?

OpenStudy (anonymous):

yeah

OpenStudy (anonymous):

Hmm, this isn't making very much sense to me :/ You say it's due in 15 minutes?

OpenStudy (anonymous):

awww its ok :/

OpenStudy (anonymous):

huuuuuuuu

OpenStudy (anonymous):

but i can still submit even it is late

OpenStudy (anonymous):

Well I am getting this now

OpenStudy (anonymous):

cout << "\nAfter transfer... \n" << endl; //transfer the entry in array 1 to array 2. for(int i=0; i<5; i++) { arr2[0][i] = arr1[1][i]; arr2[1][i] = arr1[0][i]; }

OpenStudy (anonymous):

And I changed the second print statement to..

OpenStudy (anonymous):

cout << "arr2" << endl; //print the second array for(int j=0; j<5; j++) { cout << arr2[0][j] << " " << arr2[1][4-j] << endl; }

OpenStudy (anonymous):

uhh

OpenStudy (anonymous):

#include<iostream> using namespace std; int main() { int arr1[2][5]={{1,2,3,4,5}, {10,9,8,7,6}}; int arr2[5][2]={0}; cout << "\nAfter transfer... \n" << endl; //transfer the entry in array 1 to array 2. for(int i=0; i<5; i++) { arr2[0][i] = arr1[1][i]; } for(int i=0; i<5; i++) { arr2[1][i] = arr1[0][i]; } cout << "arr1" << endl; //print the first array for(int j=0; j<5; j++) { cout << arr1[0][j] << " " << arr1[1][4-j] << endl; } cout << endl; cout << "arr2" << endl; //print the second array for(int ii=0; ii < 5; ii++) { cout << arr2[0][ii] << " " << arr2[1][4-ii] << endl; } cout << endl; // just makes the program pause // So I can view what is happening int pause; cin >> pause; return 0; }

OpenStudy (anonymous):

OpenStudy (anonymous):

Is this correct?

OpenStudy (anonymous):

no...

OpenStudy (anonymous):

Hmm, What is wrong with it?

OpenStudy (anonymous):

sorry..

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!