Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package desafiosEuler;
- import java.util.Scanner;
- public class Menornumero {
- public static void main(String[] args) {
- int n;
- Scanner sc = new Scanner(System.in);
- Scanner hue = new Scanner(System.in);
- System.out.println("Digite a quantidade de números: ");
- n = sc.nextInt();
- int[] vetor = new int[n+1];
- int[] menor = new int[1];
- vetor[0] = 2147483647;
- for(int i = 0; i < n; i++) {
- System.out.println("Digite o numero de ordem "+(i+1)+" : ");
- vetor[i+1] = sc.nextInt();
- vetor[i+1] = metodo(vetor[i], vetor[i + 1]);
- }
- System.out.println("");
- System.out.println("O menor número é "+vetor[n]+". E ele estava na posição de ordem: "+n);
- }
- public static int metodo(int x1, int x2) {
- int z = 0;
- if(x1 > x2) {
- z = x2;
- }
- if(x1 < x2) {
- z = x1;
- }
- return z;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement