-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpat1024.c
More file actions
56 lines (51 loc) · 995 Bytes
/
Copy pathpat1024.c
File metadata and controls
56 lines (51 loc) · 995 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
48
49
50
51
52
53
54
55
56
#include <stdio.h>
#include <stdlib.h>
int main()
{
char a [100];
char a1,a2;
int i=0,index,x=0;
scanf("%s",a);
a1=a[0];
i=2;
while(a[i]!='E')
i++;
index=i;
a2=a[index+1];
i=0;
while(a[index+2+i]!='\0'){
x=x*10+(a[index+2+i]-'0');
i++;
}
if(a1=='-')printf("-");
if(x==0){
for(i=0;i<index;i++)
printf("%c",a[i]);
}
if(a2=='-'){
printf("0.");
for(i=1;i<x;i++){
printf("0");
}
for(i=1;i<index;i++)
if(a[i]!='.')
printf("%c",a[i]);
}
if(a2=='+'){
if(x<index-2){
for(i=1;i<index;i++){
if(a[i]!='.')
printf("%c",a[i]);
if(i==x+2)printf(".");
}
}else{
for(i=1;i<index;i++)
if(a[i]!='.')
printf("%c",a[i]);
for(i=i-3;i<x;i++){
printf("0");
}
}
}
return 0;
}