Advertisement
Guest User

Untitled

a guest
Mar 6th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <math.h>
  4. #include <cstdlib>
  5. #include <iomanip>
  6. using namespace std;
  7.  
  8. int nowa=0;
  9. int nowa1=0;
  10. void wypelnij(float tab[4][3])
  11. {
  12. for (int i=0; i<4; i++)
  13. {
  14. for (int j=0; j<3; j++)
  15. {
  16. cout << "Element " << i << j << " wynosi: ";
  17. tab[i][j] = rand() % 50 + 5;
  18. cout << tab[i][j];
  19. cout << endl;
  20. }
  21. }
  22. }
  23.  
  24. void wypisz(float tab[4][3])
  25. {
  26. for (unsigned int i=0; i<=0; i++)
  27. for (unsigned int j=0; j<3; j++)
  28. {
  29. cout << setw(10) << tab[i][j] << setw(10);
  30. }
  31.  
  32. cout << endl;
  33.  
  34. for (unsigned int i=1; i<=1; i++)
  35. for (unsigned int j=0; j<3; j++)
  36. {
  37. cout << setw(10) << tab[i][j] << setw(10);
  38. }
  39.  
  40. cout << endl;
  41.  
  42. for (unsigned int i=2; i<=2; i++)
  43. for (unsigned int j=0; j<3; j++)
  44. {
  45. cout << setw(10) << tab[i][j] << setw(10);
  46. }
  47.  
  48. cout << endl;
  49.  
  50. for (unsigned int i=3; i<=3; i++)
  51. for (unsigned int j=0; j<3; j++)
  52. {
  53. cout << setw(10) << tab[i][j] << setw(10);
  54. }
  55.  
  56. cout << endl;
  57. }
  58.  
  59. void suma(float tab[4][3])
  60. {
  61. for (int i=0; i<4; i++)
  62. {
  63. for (int j=0; j<3; j++)
  64. {
  65. nowa=nowa + tab[i][j];
  66. }
  67. }
  68.  
  69. cout << "Suma wszystkich elementow tablicy wynosi: " << nowa;
  70. }
  71.  
  72. void max(float tab[4][3])
  73. {
  74. for (int i=0; i<4; i++)
  75. {
  76. for (int j=0; j<3; j++)
  77. {
  78. if (tab[i][j]>nowa1)
  79. nowa1 = tab[i][j];
  80. }
  81. }
  82.  
  83. cout << "Max wartosc wynosi: "<< nowa1;
  84. }
  85.  
  86. void zamiana(float tab[4][3])
  87. {
  88.  
  89. for (unsigned int i=0; i<=0; i++)
  90. for (unsigned int j=0; j<4; j++)
  91. {
  92. cout << setw(10) << tab[j][i] << setw(10);
  93. }
  94.  
  95. cout << endl;
  96.  
  97. for (unsigned int i=1; i<=1; i++)
  98. for (unsigned int j=0; j<4; j++)
  99. {
  100. cout << setw(10) << tab[j][i] << setw(10);
  101. }
  102.  
  103. cout << endl;
  104.  
  105. for (unsigned int i=2; i<=2; i++)
  106. for (unsigned int j=0; j<4; j++)
  107. {
  108. cout << setw(10) << tab[j][i] << setw(10);
  109. }
  110.  
  111. cout << endl;
  112.  
  113.  
  114. }
  115.  
  116. int main()
  117. {
  118. float tab1[4][3];
  119. wypelnij(tab1);
  120. cout << endl;
  121. zamiana (tab1);
  122. cout << endl;
  123. wypisz (tab1);
  124. cout << endl;
  125. suma (tab1);
  126. cout << endl;
  127. max (tab1);
  128. getch ();
  129. return 0;
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement