Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- void drawNumbers( int t[], int tabSize, int a, int b )
- {
- srand(time(NULL));
- int i = 0;
- int numbers;
- do
- {
- numbers = (rand() % a) + b;
- t[ i ] = numbers;
- i++;
- }
- while( i < tabSize );
- }
- void writeOut(int t[], int tabSize)
- {
- int i = 0;
- do
- {
- cout << t[i] << ", ";
- i++;
- }
- while(i < tabSize);
- }
- int calculateTheSum(int t[], int tabSize)
- {
- int i = 0;
- int sum = 0;
- do
- {
- sum = t[i] + sum;
- i++;
- }
- while(i < tabSize);
- return(sum);
- }
- int main()
- {
- int table[ 999 ];
- drawNumbers( table, 999, 7, 4 );
- writeOut( table, 999 );
- int tabSum = calculateTheSum( table, 999 );
- cout << "Suma liczb wynosi: " << tabSum << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment