Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
23b4b20
commit 6d06abb
Showing
1 changed file
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
#include <iostream> | ||
#include <cstdio> | ||
#include <cstring> | ||
#include <algorithm> | ||
#include <cstdlib> | ||
#define endl '\n' | ||
|
||
using namespace std; | ||
|
||
const int MAXN = 105; | ||
|
||
char str[MAXN]; | ||
|
||
int main() | ||
{ | ||
while(scanf("%s",str) == 1) | ||
{ | ||
int i = 0,mark1 = -1,mark2,f1,f2,f3; | ||
|
||
f1 = 1,f2 = 1,f3 = 1; | ||
|
||
while((str[i] > '9' || str[i] <= '0')) | ||
{ | ||
if(str[i] == '-') | ||
{ | ||
i++; | ||
continue; | ||
} | ||
if(str[i] == '.') | ||
{ | ||
mark1 = i; | ||
break; | ||
} | ||
if(str[i] == 'e') | ||
{ | ||
mark2 = i; | ||
break; | ||
} | ||
str[i] = -1; | ||
i++; | ||
} | ||
|
||
if(str[i] <= '9' && str[i] > '0') | ||
{ | ||
f3 = 0; | ||
} | ||
|
||
while(str[i] != 'e') | ||
{ | ||
if(str[i] == '.')mark1 = i; | ||
i++; | ||
} | ||
mark2 = i; | ||
//cout << str[mark2] << endl; | ||
|
||
//cout << mark1 << endl; | ||
int j; | ||
for(j = i - 1;j > mark1 && mark1 != -1;j--) | ||
{ | ||
if(str[j] > '0' && str[j] <= '9') | ||
{ | ||
f2 = 0; | ||
break; | ||
} | ||
str[j] = -1; | ||
} | ||
if(f2 && !f3)str[mark1] = -1; | ||
|
||
|
||
int l = strlen(str) - 1; | ||
for(i = mark2 + 1;str[i];i++) | ||
{ | ||
if(str[i] == '+') | ||
{ | ||
str[i] = -1; | ||
continue; | ||
} | ||
if(str[i] == '0' && f1) | ||
{ | ||
str[i] = -1; | ||
continue; | ||
} | ||
if(str[i] > '0' && str[i] <= '9') | ||
{ | ||
f1 = 0; | ||
break; | ||
} | ||
} | ||
|
||
int f4 = 0,f5 = 1; | ||
//cout << f3 << endl; | ||
if(f3)cout << 0; | ||
for(i = 0;str[i];i++) | ||
{ | ||
if(str[i] == -1)continue; | ||
if(str[i] == '.')f4 = 1; | ||
if(f4 && str[i] >= '0' && str[i] <= '9')f5 = 0; | ||
if(str[i] == 'e' && f4 && f5)cout << 0; | ||
cout << str[i]; | ||
} | ||
if(f1)cout << 0; | ||
cout << '\n'; | ||
} | ||
return 0; | ||
} |