0
Convert one dimensional array (array[8]) to two dimensional array (array[2][4]) .
please help
11 ответов
+ 3
Martin Taylor thank you
+ 2
int main()
{
int k[8]={15,3,21,8,3,12,5,3};
cout<<k[8];
int a[2][4]={{15,3,21,8},{3,12,5,3}}
for(int i=0;i<2;i++)
{
for(int j=0;j<4;j++)
{
cout<<a[i][j]<<" ";
}
}
return 0;
}
+ 2
mesarthim thank you
0
Younis Ahmad
Did you solve your problem in the comment or just add your code lines? It looks still error. Could you specify?
0
i don´t know
0
I checked and a ";" remaining. I added. Also if you print the elements of k, you should use a loop to write all elements.
#include <iostream>
using namespace std;
int main(){
int k[8]={15,3,21,8,3,12,5,3};
for(int s = 0; s < 8; s++){
cout<<k[s] << " ";
}
int a[2][4]={{15,3,21,8},{3,12,5,3}};
for(int i=0;i<2;i++){
for(int j=0;j<4;j++){
cout<<a[i][j]<<" ";
}
}
return 0;
}
Also, I suppose the main problem is how to convert it, am I right?
0
yes exactly
0
You should check. I hope, it helps. Happy coding!
https://code.sololearn.com/cNGPkZa7MYTq/?ref=app
0
how i can do it