-
Notifications
You must be signed in to change notification settings - Fork 2
/
B1024.cpp
50 lines (45 loc) · 818 Bytes
/
B1024.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
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
char str[10010];
scanf("%s", str);
int len = strlen(str);
if(str[0] == '-') printf("-");
int pos = 0;
while(str[pos] != 'E'){
++pos;
}
int exp = 0;
for(int i = pos + 2; i < len; ++i){
exp = exp * 10 + str[i] - '0';
}
if(exp == 0){
for(int i = 1; i < pos; ++i){
printf("%c", str[i]);
}
return 0;
}
if(str[pos+1] == '-'){
printf("0.");
for(int i = 0; i < exp - 1; ++i){
printf("0");
}
printf("%c", str[1]);
for(int i = 3; i < pos; ++i){
printf("%c", str[i]);
}
}else{
for(int i = 1; i < pos; ++i){
if(str[i] == '.') continue;
printf("%c", str[i]);
if(i == exp + 2 && pos - 3 != exp){
printf(".");
}
}
for(int i = 0; i < exp - (pos - 3); ++i){
printf("0");
}
}
return 0;
}