#1 Calcular a quantidade de voltas. Ter Out 22, 2013 2:46 am
Admin
Admin
Esse código tem a função de calcular um numero de voltas e exibir o melhor tempo , melhor volta , media dos tempos.
This code has the function to calculate a number of turns and display the best time, best lap, average times.
- Código:
#include <stdlib.h>
#include <iostream.h>
using namespace std;
int main()
{
int cont, voltas,melhor_volta;
float tempo_volta, soma_tempo, media_tempo, melhor_tempo;
cont=1;
soma_tempo=0;
cout << "\nDigite o numero de voltas: ";
cin >> voltas;
while(cont <= voltas)
{
cout << "\nDigite o tempo da volta " << cont << ": ";
cin >> tempo_volta;
if (cont == 1)
{
melhor_tempo = tempo_volta;
melhor_volta = cont;
}
if ( tempo_volta<melhor_tempo)
{
melhor_tempo=tempo_volta;
melhor_volta=cont;
}
soma_tempo=soma_tempo+tempo_volta;
cont++;
}
media_tempo = soma_tempo/voltas;
cout << "\n A melhor volta foi: " <<melhor_volta;
cout << "\n O melhor tempo foi: " <<melhor_tempo;
cout << "\n A media dos tempo e: " <<media_tempo;
cout << "\n\n";
system("PAUSE");
}