Advertisement
Guest User

Untitled

a guest
Dec 18th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void arr(int *M,int N,int ind) {
  5. int max = M[0];
  6. for (int i = 0;i < N;i++) {
  7. if (max < M[i]) {
  8. max = M[i];
  9. ind = i;
  10. }
  11. }
  12. cout << "Индекс= " << ind << endl;
  13. }
  14.  
  15. int main() {
  16. setlocale(LC_ALL, "Ru");
  17. int N,ind=0;
  18. cout<< "Введите размер массива " <<endl;
  19. cin>>N;
  20. int *M = new int[N];
  21. for (int i = 0;i<N;i++) {
  22. M[i] = rand() % 100;
  23. cout <<M[i]<<" ";
  24. }
  25. cout << endl;
  26.  
  27. arr(M, N,ind);
  28. system("pause");
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement