Advertisement
Guest User

Untitled

a guest
May 7th, 2015
317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int i,j,y, k, temp;
  6. double A[5][5]={0};
  7.  
  8. cout<<"<----------------- OUTPUT NO.1 ARRAY ELEMENTS ----------------->";
  9. cout<<endl;
  10. for(i=0,y=1; i<5; i++)
  11. {
  12. {
  13. for(j=0; j<5; j++,y++)
  14. A[i][j] = y;
  15. }
  16. }
  17. for(i=0; i<5; i++)
  18. {
  19. for(j=0; j<5; j++)
  20.  
  21. cout<<A[i][j]<<"\t";
  22. cout<<endl;
  23.  
  24. }
  25. cout<<endl;
  26. cout<<"<------ OUTPUT NO.2 INTERCHANGE ROW 2 WITH ROW 4 ELEMENTS ------->";
  27. cout<<endl;
  28.  
  29. for(i=0,y=1; i<5; i++)
  30. {
  31. {
  32. for(j=0; j<5; j++,y++)
  33. A[i][j] = y;
  34. }
  35. }
  36. for(j=0; j<5; j++,y++)
  37. {
  38. temp=A[1][j];
  39. A[1][j]=A[3][j];
  40. A[3][j]=temp;
  41.  
  42. }
  43.  
  44. for(i=0; i<5; i++)
  45. {
  46. for(j=0; j<5; j++)
  47.  
  48. cout<<A[i][j]<<"\t";
  49. cout<<endl;
  50. }
  51.  
  52. cout<<endl;
  53. cout<<"<------ OUTPUT NO.3 INTERCHANGE COL. 3 WITH COL. 5 ELEMENTS ------>";
  54. cout<<endl;
  55.  
  56. for(i=0,y=1;i<5;i++)
  57. {
  58. {
  59. for(j=0;j<5;j++,y++)
  60. A[i][j]=y;
  61. }
  62. }
  63. for(i=0;i<5;i++)
  64. {
  65. temp=A[i][2];
  66. A[i][2]=A[i][4];
  67. A[i][4]=temp;
  68. }
  69.  
  70. for(i=0; i<5;i++)
  71. {
  72. for(j=0; j<5; j++)
  73. cout<<A[i][j]<<"\t ";
  74. cout<<endl;
  75. }
  76.  
  77. cout<<endl;
  78. cout<<"<-------- OUTPUT NO.4 INTERCHANGE THE DIAGONAL ELEMENTS -------->";
  79. cout<<endl;
  80.  
  81. for(i=0,y=1;i<5;i++)
  82. {
  83. {
  84. for(j=0;j<5;j++,y++)
  85. A[i][j]=y;
  86. }
  87. }
  88.  
  89. for(i=0,k=4;i<=4;i++,k--)
  90. {
  91. temp=A[i][i];
  92. A[i][i]=A[i][k];
  93. A[i][k]=temp;
  94. }
  95.  
  96.  
  97. for(i=0; i<5;i++)
  98. {
  99. for(j=0; j<5; j++)
  100. cout<<A[i][j]<<"\t ";
  101. cout<<endl;
  102. }
  103.  
  104.  
  105. system("pause");
  106.  
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement