Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <iostream>
- using namespace std;
- ///////////////////////////////////////////////////
- int main() //
- {
- setlocale(LC_ALL, "rus");
- int *a,
- n,
- i,
- min = 99999,
- max = 0,
- minnum,
- maxnum;
- cout << "Введите длину последовательности: "; cin >> n;
- a = (int*)malloc(n * 4);
- cout << "Введите последовательность: " << endl;
- for(i=0; i < n; i++) cin >> a[i]; //scanf("%d", &a[i]);
- for(i=0; i<n; i++ )
- {
- if(a[i] < min)
- {
- min = a[i];
- minnum = i;
- }
- }
- for(i=0; i<n; i++)
- {
- if(a[i] > max)
- {
- max = a[i];
- maxnum = i;
- }
- }
- cout << "номер минимального элемента: " << minnum+1
- << endl << "номер максимального элемента: " << maxnum+1 << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement