fork(3) download
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.  
  7. int n=0,m=0; // 2D array nRow, nCol
  8. int a[n][m];
  9. int i,j; // цикъл въвеждане 2D
  10. int q,p,t; // for 2D=>1D
  11. int b[100];
  12. int r; // for cout
  13. cout<<"Enter the array's number of rows and columns: ";
  14. cin>>n>>m;
  15.  
  16. // entering values for the 2D array
  17. for (i = 0;i<=n;i++)
  18. {
  19. for (j = 0;j<=m;j++)
  20. {
  21. cout<<"a["<<i<<"]["<<j<<"]="<<endl;
  22. cin>>a[i][j];
  23. cin.ignore();
  24.  
  25.  
  26. }
  27. }
  28.  
  29. // Most likely the failzone IMO
  30. for (q = 0;q<=i;q++)
  31. {
  32. for (t = 0;t<=i*j+j;t++)
  33. {
  34. b[t] = a[i][j];
  35. }
  36. }
  37. // attempting to print the 1D values
  38. cout<<"The values in the array are"<<"\n";
  39. for(r=0;r<=t;r++)
  40. {
  41. cout<<"b["<<r<<"] = "<<b[r]<<endl;
  42. }
  43.  
  44. cin.get();
  45. return 0;
  46. }
  47.  
Success #stdin #stdout 0s 3300KB
stdin
Standard input is empty
stdout
Enter the array's number of rows and columns: a[0][0]=
The values in the array are
b[0] = 0
b[1] = 0
b[2] = 0
b[3] = 134513116