Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <time.h>
- #include <stdlib.h>
- #include <Windows.h>
- using namespace std;
- int main()
- {
- const int MAX_tab = 100;
- int a, b, x, max=0, min=0, counter=0;
- int tab[MAX_tab];
- float srednia=0;
- srand(time(NULL));
- cout << "Y=(x^2-a)(x-b) \n" << "Podaj wartosci a i b \n";
- cout << "a: ";
- cin >> a;
- cout << "b: ";
- cin >> b;
- for (int i=0; i < MAX_tab; i++)
- {
- x = rand() % 101 - 50;
- tab[i] = (x*x - a)*(x - b);
- if (tab[i] == tab[0])
- {
- max = tab[0];
- min = tab[0];
- }
- if (max < tab[i])
- {
- max = tab[i];
- }
- if (min > tab[i])
- {
- min = tab[i];
- }
- srednia = srednia + tab[i];
- counter++;
- }
- cout <<"\n"<< "Najwieksza wartosc w tabeli to " << max << " a najmniejsza to " << min;
- cout <<"\n"<< "Srednia wszystkich wynikow to " << srednia / counter;
- cout << "\n";
- cout << "\n";
- for (int i = 0; i < MAX_tab; i++)
- {
- cout << setw(10) << tab[i];
- }
- cout << "\n";
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement