Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int tab[10][10];
  6. for (int i = 0; i < 10; i++) {
  7. for (int j = 0; j < 10; j++) {
  8. tab[i][j] = rand();
  9. cout << tab[i][j] << " ";
  10. }
  11. cout << endl;
  12. }
  13. int max = 32*8;
  14. int min=32*8;
  15. int avg=0;
  16. int counter=0;
  17. for (int i = 0; i < 10; i++) {
  18. for (int j = 0; j < 10; j++) {
  19. if (tab[i][j] > max) {
  20. max = tab[i][j];
  21. }
  22. if (tab[i][j] < min) {
  23. min = tab[i][j];
  24. }
  25. }
  26. }
  27. for (int a = 0; a < 10; a++) {
  28. for (int b=0; b < 10; b++) {
  29. avg = avg + tab[a][b];
  30. counter++;
  31. }
  32. }
  33. cout <<"Max value is "<< max<<endl;
  34. cout << "Min value is " << min << endl;
  35. cout << "Avg value is " << avg / counter;
  36. cout << endl << endl << endl;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement