Guest User

Untitled

a guest
Jan 22nd, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4.  
  5. using namespace std;
  6.  
  7. void drawNumbers( int t[], int tabSize, int a, int b )
  8. {
  9. srand(time(NULL));
  10. int i = 0;
  11. int numbers;
  12. do
  13. {
  14. numbers = (rand() % a) + b;
  15. t[ i ] = numbers;
  16. i++;
  17. }
  18. while( i < tabSize );
  19.  
  20. }
  21.  
  22. void writeOut(int t[], int tabSize)
  23. {
  24. int i = 0;
  25. do
  26. {
  27. cout << t[i] << ", ";
  28. i++;
  29. }
  30. while(i < tabSize);
  31. }
  32.  
  33. int calculateTheSum(int t[], int tabSize)
  34. {
  35. int i = 0;
  36. int sum = 0;
  37. do
  38. {
  39. sum = t[i] + sum;
  40.  
  41. i++;
  42. }
  43. while(i < tabSize);
  44. return(sum);
  45. }
  46.  
  47. int main()
  48. {
  49.  
  50. int table[ 999 ];
  51. drawNumbers( table, 999, 7, 4 );
  52. writeOut( table, 999 );
  53. int tabSum = calculateTheSum( table, 999 );
  54. cout << "Suma liczb wynosi: " << tabSum << endl;
  55.  
  56. return 0;
  57. }
Add Comment
Please, Sign In to add comment