Advertisement
Guest User

Subo nyo titi ko

a guest
Mar 30th, 2015
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. int x[2][4] = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 } };
  9. int y[2][4] = { { 9, 10, 11, 12 }, { 13, 14, 15, 16 } };
  10. int a[16] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
  11.  
  12.  
  13. cout << "Printing the entire array: \n";
  14. for (int t = 0; t <16; t++){
  15.  
  16. cout << " " << a[t];
  17. }
  18.  
  19. cout << "\nPrinting per row: \n";
  20. for (int r = 0; r < 2; r++){
  21. for (int c = 0; c < 4; c++){
  22. cout << " " << x[r][c] << "";
  23. }
  24. cout << endl;
  25. }
  26. for (int r2 = 0; r2 < 2; r2++){
  27. for (int c2 = 0; c2 < 4; c2++){
  28. cout << " " << y[r2][c2] << "";
  29.  
  30. }
  31. cout << endl;
  32. }
  33.  
  34. int q[2][4] = { { 1, 5, 9, 13 }, { 2, 6, 10, 14 } };
  35. int w[2][4] = { { 3, 7, 11, 15 }, { 4, 8, 12, 16 } };
  36.  
  37. cout << "Printing per column: \n";
  38. for (int r = 0; r < 2; r++){
  39. for (int c = 0; c < 4; c++){
  40. cout << " " << q[r][c] << "";
  41. }
  42. cout << endl;
  43.  
  44. }
  45. for (int r2 = 0; r2 < 2; r2++){
  46. for (int c2 = 0; c2 < 4; c2++){
  47. cout << " " << w[r2][c2] << "";
  48.  
  49. }
  50. cout << endl;
  51.  
  52. }
  53.  
  54. int e[2][4] = { { 1, 6, 11, 16 }, { 4, 7, 10, 13 } };
  55.  
  56. cout << "Printing in diagonal form:" << endl;
  57. for (int r = 0; r < 2; r++){
  58. for (int c = 0; c < 4; c++){
  59. cout << " " << e[r][c] << "";
  60. }
  61. cout << endl;
  62. }
  63. system("pause>0");
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement