-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path1024.c
More file actions
32 lines (30 loc) · 796 Bytes
/
1024.c
File metadata and controls
32 lines (30 loc) · 796 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
#include <stdio.h>
#include <stdlib.h>
#define MAXLEN 10000
int main() {
int i = 0;
char str[MAXLEN];
scanf("%s", str);
while (str[i] != 'E') i++;
int count = 0, exp = atoi(str + i + 1);
if (str[0] == '-') putchar('-');
if (exp > 0) {
putchar(str[1]);
for (i = 3; count < exp && str[i] != 'E'; i++) {
putchar(str[i]);
count++;
}
if (count == exp && str[i] != 'E') {
putchar('.');
while (str[i] != 'E') putchar(str[i++]);
}
while (count++ < exp) putchar('0');
} else {
exp *= -1;
printf("0.");
while (count++ < exp - 1) putchar('0');
for (i = 1; str[i] != 'E'; i++)
if (str[i] != '.') putchar(str[i]);
}
return 0;
}