-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1024.cpp
More file actions
91 lines (78 loc) · 1.36 KB
/
1024.cpp
File metadata and controls
91 lines (78 loc) · 1.36 KB
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
84
85
86
87
88
89
90
91
#include<iostream>
#include<string>
using namespace std;
int main(){
string s;
cin >> s;
int len = s.length();
if (s[0] == '-')
cout << "-";
int idx = 0;
for (int i = 1; i < len; i++){
if (s[i] == 'E'){
idx = i;
}
}
int exp = 0;
for (int i = idx + 2; i < len; i++){
exp =( s[i] - '0') + exp * 10;
}
if (s[idx + 1] == '-'){
if (exp > 0){
cout << "0.";
for (int j = 0; j < exp - 1; j++)
cout << "0";
for (int j = 1; j < idx; j++){
if (s[j] >= '0'&&s[j] <= '9')
cout << s[j];
}
}
else{
for (int i = 1; i < idx; i++){
if (i == 2 - exp)
cout << ".";
if (s[i] >= '0'&&s[i] <= '9')
cout << s[i];
}
}
}
else{
if (exp >(idx - 3)){
if (s[1] != '0')
cout << s[1];
/*int t = 0;
for (int j = 1; j < idx; j++){
if (s[j] != '0'&&s[j]!='.')
t = j;
}
if (t == 0)
t = idx - 1;
*/
for (int j = 3; j < idx; j++){
if (s[j] >= '0'&&s[j] <= '9')
cout << s[j];
}
for (int k = 0; k < exp - (idx - 3); k++)
cout << "0";
}
else{
if (s[1] != '0')
cout << s[1];
int t = 0;
for (int j = 3; j < idx; j++){
if (s[j] != '0')
t = j;
}
if (t == 0)
t = idx - 1;
for (int j = 3; j < idx; j++){
if (j == 3 + exp)
cout << ".";
if (s[j] >= '0'&&s[j] <= '9')
cout << s[j];
}
}
}
system("pause");
return 0;
}