-
Notifications
You must be signed in to change notification settings - Fork 126
/
solucao.cs
83 lines (73 loc) · 2.72 KB
/
solucao.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/**********************************************************************************************
*
* 2/5 - A corrida de Tartarugas
*
******************************** Desafio:
*
* A corrida de tartarugas é um esporte que cresceu muito nos últimos anos, fazendo com que
* vários competidores se dediquem a capturar tartarugas rápidas, e treina-las para faturar
* milhões em corridas pelo mundo. Porém a tarefa de capturar tartarugas não é uma tarefa muito
* fácil, pois quase todos esses répteis são bem lentos. Cada tartaruga é classificada em um
* nível dependendo de sua velocidade:
*
* Nível 1: Se a velocidade é menor que 10 cm/h .
* Nível 2: Se a velocidade é maior ou igual a 10 cm/h e menor que 20 cm/h .
* Nível 3: Se a velocidade é maior ou igual a 20 cm/h
*
* Sua tarefa é identificar qual o nível de velocidade da tartaruga mais veloz de um grupo.
*
******************************** Entrada:
*
* A entrada consiste de múltiplos casos de teste, e cada um consiste em duas linhas: A
* primeira linha contém um inteiro L (1 ≤ L ≤ 500) representando o número de tartarugas do grupo,
* e a segunda linha contém L inteiros Vi (1 ≤ Vi ≤ 50) representando as velocidades de cada
* tartaruga do grupo.
*
******************************** Saída:
*
* Para cada caso de teste, imprima uma única linha indicando o nível de velocidade da
* tartaruga mais veloz do grupo.
*
**********************************************************************************************/
using System;
class CorridaDeTartaturgas
{
public static void Main()
{
int quantidadeEntradas = 3;
while(quantidadeEntradas > 0)
{
var numeroQuantidade = Int32.Parse(Console.ReadLine());
if(numeroQuantidade >= 1 && numeroQuantidade <= 500)
{
string[] tartarugas = Console.ReadLine().Split(" ");
var maiorVelocidade = Int32.Parse(tartarugas[0]);
for(int i = 1; i < numeroQuantidade; i++)
{
var tartaruga = Int32.Parse(tartarugas[i]);
if( tartaruga > maiorVelocidade)
{
maiorVelocidade = tartaruga;
}
}
if(maiorVelocidade < 10)
{
Console.WriteLine(1);
}
else if(maiorVelocidade >= 10 && maiorVelocidade < 20)
{
Console.WriteLine(2);
}
else if(maiorVelocidade >= 20)
{
Console.WriteLine(3);
}
quantidadeEntradas--;
}
else
{
Console.WriteLine("Insira um número entre 1 e 500");
}
}
}
}