Last active
June 26, 2020 20:12
-
-
Save gluschenko/8c3da5c252d1633ba5c07f8f7c171b86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdlib> | |
using namespace std; | |
int getMax(int *a, int size){ | |
int n = -2147483648; | |
for(int i = 0; i < size; i++){ | |
if(a[i] > n) n = a[i]; | |
} | |
return n; | |
} | |
int getMin(int *a, int size){ | |
int n = 2147483647; | |
for(int i = 0; i < size; i++){ | |
if(a[i] < n) n = a[i]; | |
} | |
return n; | |
} | |
int main(int argc, char** argv) { | |
int sizeA = 0; | |
int sizeC = 0; | |
cout << "Size of A = "; | |
cin >> sizeA; | |
cout << "Size of C = "; | |
cin >> sizeC; | |
int* A = (int*)malloc(sizeA * sizeof(int)); | |
int* C = (int*)malloc(sizeC * sizeof(int)); | |
for(int i = 0; i < sizeA; i++){ | |
cout << "A[" << i << "] = "; | |
cin >> A[i]; | |
} | |
for(int i = 0; i < sizeC; i++){ | |
cout << "C[" << i << "] = "; | |
cin >> C[i]; | |
} | |
cout << "Max A: " << getMax(A, sizeA) << endl; | |
cout << "Min B: " << getMin(C, sizeC) << endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment