-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path441_Contar_mucho.cpp
77 lines (70 loc) · 1.27 KB
/
441_Contar_mucho.cpp
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
// Usuario de Acepta el reto: jjjjjjjp022
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
string incremento(string t, int elem, int punt);
int main()
{
string t;
while (cin >> t)
{
cout << incremento(t, t.size() - 1, 1) << endl;
}
return 0;
}
string incremento(string t, int elem, int punt)
{
switch (t[elem])
{
case '0':
t[elem] = '1';
break;
case '1':
t[elem] = '2';
break;
case '2':
t[elem] = '3';
break;
case '3':
t[elem] = '4';
break;
case '4':
t[elem] = '5';
break;
case '5':
t[elem] = '6';
break;
case '6':
t[elem] = '7';
break;
case '7':
t[elem] = '8';
break;
case '8':
t[elem] = '9';
break;
case '9':
t[elem] = '0';
if (elem > 0)
{
t = incremento(t, elem - 1, ++punt);
}
else
{
if (punt % 3 == 0)
{
t = "1." + t;
}
else
{
t = '1' + t;
}
}
break;
case '.':
t = incremento(t, elem - 1, punt);
break;
}
return t;
}