/
solucao.cs
41 lines (31 loc) · 927 Bytes
/
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
using System;
namespace DesafiosIntermediariosC {
class CrescimentoPopulacional {
static void Main(string[] args) {
int t = Convert.ToInt32(Console.ReadLine());
int pa, pb;
int anos;
double[] arrayList = new double[4];
double cpa, cpb;
for (int i = 0; i < t; i++) {
anos = 0;
string[] valores = Console.ReadLine().Split();
pa = int.Parse(valores[0]);
pb = int.Parse(valores[1]);
cpa = double.Parse(valores[2]);
cpb = double.Parse(valores[3]);
while (pa <= pb && anos < 101) {
pa += (int)((pa*cpa)/100);
pb += (int)((pb*cpb)/100);
anos++;
if (anos > 100) {
Console.WriteLine("Mais de 1 seculo.");
}
}
if (anos <= 100) {
Console.WriteLine(anos + " anos.");
}
}
}
}
}