#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main()
{
string s;
stringstream stream;
int n;
cin >> s;
string::size_type pos = s.find('E');
string s2 = s.substr(pos + 2);
stream << s2;
stream >> n;
if (s[pos + 1] == '-')
{
if (s[0] == '-')
{
cout << s[0];
}
for (int i = 0; i < n; ++i)
{
if (i == 0)
cout << "0.";
else
cout << '0';
}
cout << s[1];
for (int i = 3; i < pos; ++i)
{
cout << s[i];
}
}
else
{
if (s[0] == '-')
{
cout << s[0];
cout << s[1];
}
else
{
cout << s[1];
}
if (n >= pos - 3) //正数的时候会遇到转换之后小数点后还有数字的情况
{
for (int i = 3; i < pos; ++i)
{
cout << s[i];
}
for (int i = 0; i < n-(pos-3); ++i)
{
cout << '0';
}
}
else
{
for (int i = 3; i < n + 3; ++i)
{
cout << s[i];
}
cout << ".";
for (int i = n + 3; i < pos; ++i)
{
cout << s[i];
}
}
}
return 0;
}
1024. 科学计数法
最新推荐文章于 2022-08-07 14:36:39 发布