Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <time.h>
- #include<math.h>
- using namespace std;
- int main() {
- int i;
- int tab[100];
- int p;
- int k;
- int suma = 0;
- int liczba = 0;
- srand (time(NULL));
- cout << "Patryk Zielewski" << endl << endl;
- cout << "Podaj poczatek przedzialu losowanych liczb: ";
- cin >> p;
- cout << "Podaj koniec przedzialu losowanych liczb: ";
- cin >> k;
- cout << endl << endl;
- for (i = 0; i <= 100; i++) {
- tab[i] = rand()%(k-p+1)+p;
- if (tab[i]%3 == 0)
- suma += tab[i];
- liczba += i;
- cout << i << ". " << tab[i] << endl;
- }
- cout << endl << endl;
- cout << "Suma liczb podzielnych przez 3 wynosi: " << suma << endl;
- cout << "Liczba podzielnych przez 3 jest: " << liczba << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement