Skip to content

Instantly share code, notes, and snippets.

@modos
Created July 9, 2022 07:43
Show Gist options
  • Save modos/044a9f45a532344b07ac434722242f8d to your computer and use it in GitHub Desktop.
Save modos/044a9f45a532344b07ac434722242f8d to your computer and use it in GitHub Desktop.
هندونه خوری
/******************************************************************************
Online C++ Compiler.
Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.
*******************************************************************************/
#include <iostream>
using namespace std;
int
largest (int arr[], int n)
{
int i;
int max = arr[0];
int index = 0;
for (i = 1; i < n; i++)
if (arr[i] > max){
max = arr[i];
index = i;
}
return index + 1;
}
int
main ()
{
int n;
cin >> n;
int arr[n];
for (int i = 0; i < n; i++)
{
cin >> arr[i];
}
cout << largest (arr, n);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment