-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProblema_1020.cpp
More file actions
47 lines (37 loc) · 766 Bytes
/
Problema_1020.cpp
File metadata and controls
47 lines (37 loc) · 766 Bytes
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
/*
@autor: Victor E. B. Rodrigues;
@data: 22/06/2021;
@nome: Idade em Dias;
*/
#include <bits/stdc++.h>
#include <stack>
using namespace std;
void printIdadeAMD(int& dias, stack<int>& pilha){
if(!pilha.empty()){
int valor = pilha.top();
int tempo = dias/valor;
if (tempo > 0)
dias -= tempo*valor;
if(pilha.top() == 365)
cout << tempo << " ano(s)" << endl;
else if(pilha.top() == 30)
cout << tempo << " mes(es)" << endl;
else
cout << tempo << " dia(s)" << endl;
pilha.pop();
printIdadeAMD(dias, pilha);
}
}
int main() {
cin.tie(NULL);
cout.tie(NULL);
ios::sync_with_stdio(0);
stack<int> pilha;
pilha.push(1);
pilha.push(30);
pilha.push(365);
int N;
cin >> N;
printIdadeAMD(N, pilha);
return 0;
}