## Algorithm

Problem Name: beecrowd | 1180

# Lowest Number and Position

Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

Write a program that reads a number N. This N is the size of a array X[N]. Next, read each of the numbers of X, find the smallest element of this array and its position within the array, printing this information.

## Input

The first line of input contains one integer N (1 < N <1000), indicating the number of elements that should be read to an array X[N] of integer numbers. The second row contains each of the N values, separated by a space. Remember that no input will have repeated numbers.

## Output

The first line displays the message “Menor valor:” followed by a space and the lowest number read in the input. The second line displays the message “Posicao:” followed by a space and the array position in which the lowest number is, remembering that the array starts at the zero position.

 Input Sample Output Sample 10 1 2 3 4 -5 6 7 8 9 10 Menor valor: -5 Posicao: 4

## Code Examples

### #1 Code Example with C++ Programming

```Code - C++ Programming```

``````
#include <iostream>

using namespace std;

int main() {

int n,l,p;
cin>>n;
int a[n];
for(int i = 0; i  <  n; i++)
{
cin>>a[i];
}
l=a[0];
p=0;
for(int i =1; i  <  n; i++)
{
if(a[i] < l)
{
p=i;
l=a[i];

}
}
printf("Menor valor: %d\n",l);
printf("Posicao: %d\n",p>;

return 0;
}
``````
Copy The Code &

Input

cmd
10 1 2 3 4 -5 6 7 8 9 10

### #2 Code Example with Javascript Programming

```Code - Javascript Programming```

``````
const lines = input.split('\n');

let n = Number(lines.shift());
let numeros = lines.shift().split(" ");
let min = 0;
let posicao = 0;
for(var i = 0; i  <  n; i++){
x = parseInt(numeros[i]);
if(i===0) {
min = x; posicao = i;
}
else if(x < min){
min = x; posicao = i;
}
}
console.log(`Menor valor: \${min}
Posicao: \${posicao}`>;
``````
Copy The Code &

Input

cmd
10 1 2 3 4 -5 6 7 8 9 10

### #3 Code Example with Python Programming

```Code - Python Programming```

``````
n = int(input())
num = input().split(' ')
numeros=[]
for i in range(0, n):
p = int(num[i])
numeros+=[p]
print(f'''Menor valor: {min(numeros)}
Posicao: {numeros.index(min(numeros))}''')
``````
Copy The Code &

Input

cmd
10 1 2 3 4 -5 6 7 8 9 10