fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6.  
  7.  
  8. //your code goes here
  9.  
  10.  
  11.  
  12.  
  13. //fh - first half
  14. //sh - second half
  15.  
  16. //Size - размер исходного массива(8 элементов)
  17. #define Size 8
  18.  
  19. //N - ishodnii massiv
  20. int str, stlbc, fh = 0, sh = Size/2,
  21. N[8][4] = {
  22. {1, 1, 1, 1},
  23. {2, 2, 2, 2},
  24. {3, 3, 3, 3},
  25. {4, 4, 4, 4},
  26. {5, 5, 5, 5},
  27. {6, 6, 6, 6},
  28. {7, 7, 7, 7},
  29. {8, 8, 8, 8}}, M[8][4] = {0};
  30.  
  31.  
  32. //M - rezultiruyushii massiv
  33. for(str = 0; str < Size; str+=2)
  34. {
  35. for(stlbc = 0; stlbc < 4; stlbc++)
  36. M[str][stlbc] = N[fh][stlbc];
  37. for(stlbc = 0; stlbc < 4; stlbc++)
  38. M[str+1][stlbc] = N[sh][stlbc];
  39. fh++;
  40. sh++;
  41. }
  42.  
  43. //Vivod elementov v console
  44. cout << "\n\nRezultiruyushii massiv:\n";
  45. for(str = 0; str < Size; str++)
  46. {
  47. for(stlbc = 0; stlbc < 4; stlbc++)
  48. {
  49. cout << M[str][stlbc] << " ";
  50. }
  51. cout << "\n";
  52. }
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60. return 0;
  61. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout

Rezultiruyushii massiv:
1 1 1 1 
5 5 5 5 
2 2 2 2 
6 6 6 6 
3 3 3 3 
7 7 7 7 
4 4 4 4 
8 8 8 8