Ir ao conteúdo
  • Cadastre-se

Cronometro no java


Posts recomendados

System.currentTimeMillis não retorna o valor do tempo que foi feito o processamento daqueles dados.(tipo um cronometro).

Sempre retorna ZERO,alguem sabe o que está dando errado?

import java.util.Scanner;
public class nome {
    public static Scanner ler;
    
    public static void main(String[] args) {
        // TODO Auto-generated method stub
            ler = new Scanner(System.in);
            int v;
            System.out.println("Digite o números de casas no vetor que deseja?");
            v = ler.nextInt();
            int vetor[] = new int[v];
            for (int i = ; i < vetor.length; i++) {
                System.out.print("Digite o " + (i + 1) + "º valor");
                vetor = ler.nextInt();
            }
            
            bubblesort(vetor);
            
        }
        public static void bubblesort(int vet[]){
            int tam = vet.length;
            int i, j, aux;
            long tinicial = System.currentTimeMillis();            
                for(i = ; i < (tam - 1); i++){
                    for(j = 1; j < tam; j++){
                        if(vet[j] < vet[j - 1]){
                            aux = vet[j];
                            vet[j] = vet[j - 1];
                            vet[j - 1] = aux;
                    }
                }
            }
                long tfinal = System.currentTimeMillis();
                System.out.println("Tempo = " + (tfinal - tinicial));
                
                for(i = ; i < vet.length; i++){
                    System.out.print(vet);
                }
        }

 

Link para o comentário
Compartilhar em outros sites

  • 2 semanas depois...
Visitante
Este tópico está impedido de receber novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

 

GRÁTIS: ebook Redes Wi-Fi – 2ª Edição

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!