Guest User

Untitled

a guest
Oct 1st, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 KB | None | 0 0
  1. /*
  2. Assignment designed by Jannatul Maowa, Assistant Professor, CS, AIUB
  3. For query: [email protected]
  4. */
  5.  
  6. #include <iostream>
  7. using namespace std;
  8. #define row 5
  9. #define col 5
  10.  
  11. void input2DArray(int array[][col])
  12. {
  13. int i,j;
  14. for(i = 0; i<row; i++)
  15. {
  16. for(j =0; j<col; j++)
  17. {
  18. cin>>array[i][j];
  19. }
  20. }
  21. }
  22.  
  23. void output2DArray(int array[][col])
  24. {
  25. int i,j;
  26. cout<<"\n output of 2D Array: \n";
  27. for(i = 0; i<row; i++)
  28. {
  29. for(j =0; j<col; j++)
  30. {
  31. cout<<array[i][j];
  32. }
  33. cout<<endl;
  34. }
  35. cout<<endl;
  36. }
  37.  
  38.  
  39. void columnRotateRight(int array[][col])
  40. {
  41. // your code here
  42.  
  43. /*
  44. suppose an array of dim = ( 3 x 3) having the following values
  45. 1 2 3
  46. 4 5 6
  47. 7 8 9
  48. after this function being executed the array will be looks like:
  49. 3 1 2
  50. 6 4 5
  51. 9 7 8
  52. */
  53. }
  54.  
  55. void columnRotateLeft(int array[][col])
  56. {
  57. // your code here
  58. /*
  59. suppose an array of dim = ( 3 x 3) having the following values
  60. 1 2 3
  61. 4 5 6
  62. 7 8 9
  63. after this function being executed the array will be looks like:
  64. 2 3 1
  65. 5 6 4
  66. 8 9 7
  67. */
  68. }
  69.  
  70. void rowRotateUp(int array[][col])
  71. {
  72. // your code here
  73.  
  74. /*
  75. suppose an array of dim = ( 3 x 3) having the following values
  76. 1 2 3
  77. 4 5 6
  78. 7 8 9
  79. after this function being executed the array will be looks like:
  80. 4 5 6
  81. 7 8 9
  82. 1 2 3
  83. */
  84. }
  85.  
  86. void rowRotateDown(int array[][col])
  87. {
  88. // your code here
  89. /*
  90. suppose an array of dim = ( 3 x 3) having the following values
  91. 1 2 3
  92. 4 5 6
  93. 7 8 9
  94. after this function being executed the array will be looks like:
  95. 7 8 9
  96. 1 2 3
  97. 4 5 6
  98.  
  99. */
  100. }
  101.  
  102. void sortColumnWise(int array[][col])
  103. {
  104. // your code here
  105. //sorting will be in ascending order
  106. /*
  107. suppose an array of dim = ( 3 x 3) having the following values
  108. 9 8 7
  109. 6 5 4
  110. 1 2 3
  111. after this function being executed the array will be looks like:
  112. 1 2 3
  113. 6 5 4
  114. 9 8 7
  115.  
  116. */
  117. }
  118.  
  119.  
  120.  
  121. void sortRowWise(int array[][col])
  122. {
  123. // your code here
  124. //sorting will be in ascending order
  125.  
  126. /*
  127. suppose an array of dim = ( 3 x 3) having the following values
  128. 9 8 7
  129. 6 5 4
  130. 1 2 3
  131. after this function being executed the array will be looks like:
  132. 7 8 9
  133. 4 5 6
  134. 1 2 3
  135.  
  136. */
  137. }
  138.  
  139. int main()
  140. {
  141.  
  142.  
  143. int array[row][col];
  144. input2DArray(array);
  145. output2DArray(array);
  146.  
  147. columnRotateRight(array);
  148. cout<<"output after columnRotateRight: \n";
  149. output2DArray(array);
  150.  
  151.  
  152. columnRotateLeft(array);
  153. cout<<"output after columnRotateLeft: \n";
  154. output2DArray(array);
  155.  
  156.  
  157. rowRotateUp(array);
  158. cout<<"output after rowRotateUp: \n";
  159. output2DArray(array);
  160.  
  161.  
  162. rowRotateDown(array);
  163. cout<<"output after rowRotateDown: \n";
  164. output2DArray(array);
  165.  
  166.  
  167. sortColumnWise(array);
  168. cout<<"output after sortColumnWise: \n";
  169. output2DArray(array);
  170.  
  171.  
  172. sortRowWise(array);
  173. cout<<"output after sortRowWise: \n";
  174. output2DArray(array);
  175.  
  176.  
  177. return 0;
  178. }
Advertisement
Add Comment
Please, Sign In to add comment