Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- int n;
- cout << "nhap n :";
- cin >> n;
- int *a = new int[n];
- for (int i = 0; i < n; i++) {
- cout << "nhap a[" << i + 1 << "]";
- cin >> a[i];
- }
- int min = a[1];
- for (int i = 0; i < n; i++) {
- if (min > a[i]) {
- min = a[i];
- }
- }
- int max = a[n - 1];
- for (int i = 0; i < n; i++) {
- if (max < a[i]) {
- max = a[i];
- }
- }
- cout << min << " " << max;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement