how to transfer/array manipulation in 2dimensional array ?? please help..
@Mertsj
@satellite73
please help guys
@Ashleyisakitty
@whpalmer4
@lalaly
@zepdrix
help guys
Sorry. I don't know this stuff.
aww its ok THANK YOU parin @Mertsj
@timo86m
help guys..
@wolfe8
sorry
awwwwwwwwwwwww
I learned this years ago for C. What do you use?
#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;
im using c++
im not sure in my answer
Yeah it's kinda different than C by a bit. You might wanna Google this. There are a lot of programming forums.
no.. there's no no answer in google
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
??
i dont know what to put in the program to display like that .. :/
please help...........
@bbkzr31 hey its you ^_^
lol
hahaah sorry last time
oh np, I had to go work on some math :P
Your just wanting to start with one array and copy the contents of that array into another in C++?
no i just need to change /add the TRANSFER statement
to display this number 1 2 3 4 5 6 7 8 9 10 in 2Dimensional arrays
and i only have 1 hour to answer that ;/ whahah
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
You posted some code earlier in the discussion is that working correctly?
no.. i dont know if it is working correctly.. that only my wrong idea..
so you aren't able to compile the code?
and test it?
no i dont have a compiler right now
#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; }
Here is what you get when you run the code right now
aww it is still wrong..
i need to display it by [2][5]
1 2 3 4 5 6 7 8 9 10
is that what you want the second array to display?
no
oh, you want to change the formatting of the print statement?
thats for the array 1
array 2 is like this 10 9 8 7 6 5 4 3 2 1
ok
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?
not understanding what you mean
your right ...
yes it should be in different statement..
@bbkzr31 still there???
//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.
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?
array 1 is already correct..
after that the second array should display like this 1 2 3 4 5 6 7 8 9 10
So array one is already displaying correctly, but array two is not copying or being displayed correctly?
yeah
Hmm, this isn't making very much sense to me :/ You say it's due in 15 minutes?
awww its ok :/
huuuuuuuu
but i can still submit even it is late
Well I am getting this now
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]; }
And I changed the second print statement to..
cout << "arr2" << endl; //print the second array for(int j=0; j<5; j++) { cout << arr2[0][j] << " " << arr2[1][4-j] << endl; }
uhh
#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; }
Is this correct?
no...
Hmm, What is wrong with it?
sorry..
Join our real-time social learning platform and learn together with your friends!