Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <cmath>
  4. #define G 5
  5. #define F 5
  6. using namespace std;
  7. void zapulva(double array[][G], size_t rows);
  8. void izpisva(double array[F][G]);
  9. int main()
  10. {
  11. double mat[F][G];
  12. zapulva(mat, F);
  13. izpisva(mat);
  14.  
  15.  
  16.  
  17. }
  18. void zapulva(double array[][G], size_t rows)
  19. {
  20. srand(time(NULL));
  21. for (int i = 0; i < rows; i++)
  22. {
  23. for (int j = 0; j < G; j++)
  24. {
  25. array[i][j] = (rand() % 205 + (-55));
  26. }
  27. }
  28. for (int i = 0; i < rows; i++)
  29. {
  30. for (int j = 0; j < G; j++)
  31. {
  32. array[i][j] /= 100;
  33. }
  34. }
  35. }
  36. void izpisva(double array[F][G])
  37. {
  38. int counter = 0;
  39. for (int i = 0; i < F; i++)
  40. {
  41. for (int j = 0; j < G; j++)
  42. {
  43. if (counter< 10)
  44. {
  45. cout << "0" << counter << ":" << array[i][j] << " ";
  46. }
  47. else
  48. {
  49. cout << counter << ":" << array[i][j] << " ";
  50.  
  51. }
  52. counter++;
  53. }
  54. cout << endl;
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement