Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- void fill(int[], int);
- int fmax(int[], int);
- int fmin(int[], int);
- int main() {
- setlocale(0, "");
- srand(time(0));
- int P[13];
- int B[9];
- cout << "Массив P: ";
- fill(P, 13);
- cout << "Массив B: ";
- fill(B, 9);
- cout << endl << "max(P) = " << fmax(P, 13) << endl;
- cout << "min(P) = " << fmin(P, 13) << endl;
- cout << "max(B) = " << fmax(B, 9) << endl;
- cout << "min(B) = " << fmin(B, 9) << endl;
- double Z = ((double)fmax(P, 13) - (double)fmin(P, 13)) / ((double)fmax(B, 9) - (double)fmin(B, 9));
- cout << endl << "(max(P) - min(P)) / (max(B) - min(B)) = " << Z << endl;
- system("pause");
- }
- void fill(int array[], int length) {
- for (int i = 0; i < length; i++) {
- array[i] = rand() % 100 + 1;
- cout << array[i] << " ";
- }
- cout << endl;
- }
- int fmax(int array[], int length) {
- int max = array[0];
- for (int i = 0; i < length; i++) {
- if (array[i] > max) {
- max = array[i];
- }
- }
- return max;
- }
- int fmin(int array[], int length) {
- int min = array[0];
- for (int i = 0; i < length; i++) {
- if (array[i] < min) {
- min = array[i];
- }
- }
- return min;
- }
Advertisement
Add Comment
Please, Sign In to add comment